Research Article

Research on a Shared Bicycle Deposit Management System Based on Blockchain Technology

Algorithm 2

Decryption code for private key and public key.
//Decry the public key in pem format
 block, _ : = pem.Decode (publicKey)
 if block == nil {
  return nil, errors.New (“public key error”)
 }
 // Parsing the public key
 pubInterface, err : = x509.ParsePKIXPublicKey(block.Bytes)
 if err ! = nil {
  return nil, err
 }
 // Type discriminant
 pub : = pubInterface.(rsa.PublicKey)
 //Encryption
 return rsa.EncryptPKCS1v15 (rand.Reader, pub, origData)
}
// Decryption
func RsaDecrypt (ciphertext []byte) ([]byte, error) {
 // Decryption
 block, _ : = pem.Decode (privateKey)
 if block == nil {
  return nil, errors.New (“private key error!”)
 }
 //Resolves the private key in PKCS1 format
 priv, err : = x509.ParsePKCS1PrivateKey (block.Bytes)
 if err ! = nil {
  return nil, err
 }
 // Decryption
 return rsa.DecryptPKCS1v15 (rand.Reader, priv, ciphertext)
}