diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2017-05-09 17:10:27 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2017-05-09 17:10:27 +0800 |
commit | 3b65e413cd6b710161712b9f3149d527ea33861a (patch) | |
tree | 5d47246c6993a706a4fbfe0acb5aa17ba23d76fb /go | |
parent | 55357674fea8174d31e5242d430eb011fb935b09 (diff) | |
download | dexon-bls-3b65e413cd6b710161712b9f3149d527ea33861a.tar dexon-bls-3b65e413cd6b710161712b9f3149d527ea33861a.tar.gz dexon-bls-3b65e413cd6b710161712b9f3149d527ea33861a.tar.bz2 dexon-bls-3b65e413cd6b710161712b9f3149d527ea33861a.tar.lz dexon-bls-3b65e413cd6b710161712b9f3149d527ea33861a.tar.xz dexon-bls-3b65e413cd6b710161712b9f3149d527ea33861a.tar.zst dexon-bls-3b65e413cd6b710161712b9f3149d527ea33861a.zip |
add old methods for backward compatibility
Diffstat (limited to 'go')
-rw-r--r-- | go/bls/bls.go | 63 |
1 files changed, 59 insertions, 4 deletions
diff --git a/go/bls/bls.go b/go/bls/bls.go index 7118287..ed74a6d 100644 --- a/go/bls/bls.go +++ b/go/bls/bls.go @@ -308,8 +308,8 @@ func (pub *PublicKey) GetHexString() string { return fmt.Sprintf("%x", pub.Serialize()) } -// SetStr -func (pub *PublicKey) SetStr(s string) error { +// SetHexString +func (pub *PublicKey) SetHexString(s string) error { b, err := hex.DecodeString(s) if err != nil { return err @@ -384,8 +384,8 @@ func (sign *Sign) GetHexString() string { return fmt.Sprintf("%x", sign.Serialize()) } -// SetStr -func (sign *Sign) SetStr(s string) error { +// SetHexString +func (sign *Sign) SetHexString(s string) error { b, err := hex.DecodeString(s) if err != nil { return err @@ -435,3 +435,58 @@ func (sign *Sign) Verify(pub *PublicKey, m string) bool { func (sign *Sign) VerifyPop(pub *PublicKey) bool { return C.blsSignVerifyPop(sign.getPointer(), pub.getPointer()) == 1 } + +// for backward compatibility (these methods will be removed in the next version) +func (id *ID) String() string { + return id.GetHexString() +} + +func (id *ID) SetStr(s string) error { + if s[:2] == "0x" { + return id.SetHexString(s) + } else { + return id.SetDecString(s) + } +} + +func (sec *SecretKey) String() string { + return sec.GetHexString() +} +func (sec *SecretKey) SetStr(s string) error { + if s[:2] == "0x" { + return sec.SetHexString(s) + } else { + return sec.SetDecString(s) + } +} +func (sec *SecretKey) GetData() []byte { + return sec.Serialize() +} +func (sec *SecretKey) SetData(b []byte) error { + return sec.Deserialize(b) +} +func (pub *PublicKey) String() string { + return pub.GetHexString() +} +func (pub *PublicKey) SetStr(s string) error { + return pub.SetHexString(s) +} +func (pub *PublicKey) GetData() []byte { + return pub.Serialize() +} +func (pub *PublicKey) SetData(b []byte) error { + return pub.Deserialize(b) +} + +func (sign *Sign) String() string { + return sign.GetHexString() +} +func (sign *Sign) SetStr(s string) error { + return sign.SetHexString(s) +} +func (sign *Sign) GetData() []byte { + return sign.Serialize() +} +func (sign *Sign) SetData(b []byte) error { + return sign.Deserialize(b) +} |