pc-dart icon indicating copy to clipboard operation
pc-dart copied to clipboard

is there an example of ECDSA algorithm

Open tiantianaixuexi opened this issue 3 years ago • 5 comments

Hello, is there an example of ECDSA algorithm?

tiantianaixuexi avatar Aug 26 '20 14:08 tiantianaixuexi

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

AKushWarrior avatar Aug 26 '20 17:08 AKushWarrior

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

tiantianaixuexi avatar Aug 28 '20 09:08 tiantianaixuexi

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?

AKushWarrior avatar Aug 31 '20 18:08 AKushWarrior

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

tiantianaixuexi avatar Sep 01 '20 01:09 tiantianaixuexi

Hello @tiantianaixuexi, Is this request still valid?

redDwarf03 avatar Mar 09 '23 21:03 redDwarf03