mirror of
https://github.com/emmansun/gmsm.git
synced 2025-06-03 01:44:54 +00:00
slhdsa: provide handy methods
This commit is contained in:
parent
da0d651197
commit
6f6631236f
@ -71,7 +71,7 @@ func testData(t *testing.T, filename string, tc *slhtest) {
|
||||
context, _ := hex.DecodeString(tc.Context)
|
||||
sig, _ := hex.DecodeString(tc.Signature)
|
||||
sigOriginal := sig
|
||||
privKey, err := NewPrivateKey(skBytes, params)
|
||||
privKey, err := params.NewPrivateKey(skBytes)
|
||||
if err != nil {
|
||||
t.Fatalf("%v NewPrivateKey(%x) = %v", filename, skBytes, err)
|
||||
}
|
||||
@ -100,7 +100,7 @@ func testData(t *testing.T, filename string, tc *slhtest) {
|
||||
sig = sig[privKey.params.n*(privKey.params.len+privKey.params.hm):]
|
||||
}
|
||||
// test verify
|
||||
pub, err := NewPublicKey(pkBytes, params)
|
||||
pub, err := params.NewPublicKey(pkBytes)
|
||||
if err != nil {
|
||||
t.Fatalf("%v NewPublicKey(%x) = %v", filename, pkBytes, err)
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package slhdsa
|
||||
|
||||
import "io"
|
||||
|
||||
const (
|
||||
MAX_N = 32
|
||||
MAX_M = 49
|
||||
@ -121,3 +123,19 @@ func (p *params) leafIdxMask() uint64 {
|
||||
func (p *params) String() string {
|
||||
return p.alg
|
||||
}
|
||||
|
||||
// GenerateKey generates a new private key using the provided random source and the parameters
|
||||
// specified by the receiver.
|
||||
func (p *params) GenerateKey(rand io.Reader) (*PrivateKey, error) {
|
||||
return GenerateKey(rand, p)
|
||||
}
|
||||
|
||||
// NewPublicKey creates a new PublicKey instance from the provided byte slice using the current parameter set.
|
||||
func (p *params) NewPublicKey(bytes []byte) (*PublicKey, error) {
|
||||
return NewPublicKey(bytes, p)
|
||||
}
|
||||
|
||||
// NewPrivateKey creates a new PrivateKey instance using the provided byte slice and the current parameter set.
|
||||
func (p *params) NewPrivateKey(bytes []byte) (*PrivateKey, error) {
|
||||
return NewPrivateKey(bytes, p)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user