SM9: update readme and supplement comment

This commit is contained in:
Sun Yimin 2022-06-16 16:40:00 +08:00 committed by GitHub
parent 410b1eea3a
commit aa9e546638
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 14 deletions

View File

@ -1,5 +1,11 @@
SM9 current performance: ## SM9 current supported functions:
1.Keys generation
2.Sign/Verify
3.Key Exchange
4.Wrap/Unwrap Key
5.Encryption/Decryption (XOR mode)
## SM9 current performance:
**SM9 Sign Benchmark** **SM9 Sign Benchmark**

View File

@ -497,19 +497,21 @@ func (priv *EncryptPrivateKey) Decrypt(uid, ciphertext []byte) ([]byte, error) {
} }
// KeyExchange key exchange struct, include internal stat in whole key exchange flow. // KeyExchange key exchange struct, include internal stat in whole key exchange flow.
// Initiator's flow will be: NewKeyExchange -> InitKeyExchange -> transmission -> ConfirmResponder
// Responder's flow will be: NewKeyExchange -> waiting ... -> RepondKeyExchange -> transmission -> ConfirmInitiator
type KeyExchange struct { type KeyExchange struct {
genSignature bool genSignature bool // control the optional sign/verify step triggered by responsder
keyLength int keyLength int // key length
privateKey *EncryptPrivateKey privateKey *EncryptPrivateKey // owner's encryption private key
uid []byte uid []byte // owner uid
peerUID []byte peerUID []byte // peer uid
r *big.Int r *big.Int // random which will be used to compute secret
secret *bn256.G1 secret *bn256.G1 // generated secret which will be passed to peer
peerSecret *bn256.G1 peerSecret *bn256.G1 // received peer's secret
g1 *bn256.GT g1 *bn256.GT // internal state which will be used when compute the key and signature
g2 *bn256.GT g2 *bn256.GT // internal state which will be used when compute the key and signature
g3 *bn256.GT g3 *bn256.GT // internal state which will be used when compute the key and signature
key []byte key []byte // key will be used after key agreement
} }
// NewKeyExchange create one new KeyExchange object // NewKeyExchange create one new KeyExchange object
@ -523,7 +525,7 @@ func NewKeyExchange(priv *EncryptPrivateKey, uid, peerUID []byte, keyLen int, ge
return ke return ke
} }
// GetKey return key after key alignment // GetKey return key after key agreement
func (ke *KeyExchange) GetKey() []byte { func (ke *KeyExchange) GetKey() []byte {
return ke.key return ke.key
} }