bcgit / pc-dart

Pointy Castle - Dart Derived Bouncy Castle APIs
MIT License
237 stars 122 forks source link

is there an example of ECDSA algorithm #42

Open tiantianaixuexi opened 4 years ago

tiantianaixuexi commented 4 years ago

Hello, is there an example of ECDSA algorithm?

AKushWarrior commented 4 years ago

There is not. What are you trying to do? I can try writing one for you.

tiantianaixuexi commented 4 years ago

I want to load the private key and secret key from the file, and then encrypt and decrypt the transmitted data through ECDSA.

AKushWarrior commented 4 years ago

I want to load the private key and secret key from the file, and then encrypt and decrypt the transmitted data through ECDSA.

I don't know of a way to encode/decode keys from a file. Is there a file format you are using that I can investigate?

tiantianaixuexi commented 4 years ago

This public key and Private key are generated by me from the Go language, and its code is like this.Its format ends in .pem

`

privateKey, _ := ecdsa.GenerateKey(c, rand.Reader)
// SaveKey
// x509
x509PrivateKey, _ := x509.MarshalECPrivateKey(privateKey)

//pem
block := pem.Block{
    Type:"ecc private key",
    Bytes:x509PrivateKey,
}

//Save in file
privateFile, _ := os.Create(privatePath)
pem.Encode(privateFile,&block)

defer privateFile.Close()

////////////////////SavePublicKey//////////////////////
// x509
x509PublicKey, _ := x509.MarshalPKIXPublicKey(&privateKey.PublicKey)
//  pem
publicBlock := pem.Block{
    Type:"ecc public key",
    Bytes:x509PublicKey,
}

publicFile, _ := os.Create(publicPath)
defer publicFile.Close()

pem.Encode(publicFile,&publicBlock)

`

The following files are the private keys and keys after they are generated key.zip

redDwarf03 commented 1 year ago

Hello @tiantianaixuexi, Is this request still valid?