Documentation ¶
Index ¶
- Constants
- func Copy(in *big.Int) *big.Int
- func Get32BYtes() []byte
- func GetBig() *big.Int
- func Put32Bytes(in []byte)
- func PutBig(in *big.Int)
- type ECDSA
- type ECDSAPrivateKey
- func (key *ECDSAPrivateKey) Bytes() ([]byte, error)
- func (key *ECDSAPrivateKey) CalculatePublicKey() *ECDSAPrivateKey
- func (key *ECDSAPrivateKey) FromBytes(k []byte, opt int) error
- func (key *ECDSAPrivateKey) Public() std.PublicKey
- func (key *ECDSAPrivateKey) SetPublicKey(k *ECDSAPublicKey) *ECDSAPrivateKey
- func (key *ECDSAPrivateKey) Sign(k, digest []byte, reader io.Reader) (signature []byte, err error)
- type ECDSAPublicKey
- type ECDSASignature
Constants ¶
const ( AlgorithmNone = 0x00 AlgoP256K1 = 0x0200 AlgoP256R1 = 0x0300 AlgoP384R1 = 0x0400 AlgoP521R1 = 0x0500 AlgoP256K1Recover = 0x0600 AlgoRSA2048 = 0x1000 AlgoRSA3072 = 0x1100 AlgoRSA4096 = 0x1200 )
Algorithm identity
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ECDSA ¶
type ECDSA struct {
Opt int
}
ECDSA ECDSA instance is a tool to sign and verify. You can sign and verify via ECDSAPrivateKey and ECDSAPublicKey, ECDSA instance is just a package of ECDSAPrivateKey's Sign and ECDSAPublicKey's Verify. If you need revoke Sign or Verify at a sepcific Key many times, we recommend using ECDSAPrivateKey and ECDSAPublicKey, which avoid decode and alloc repeatedly. All in all, ECDSA is convenient; ECDSAPrivateKey and ECDSAPublicKey are faster.
type ECDSAPrivateKey ¶
type ECDSAPrivateKey struct { ECDSAPublicKey D *big.Int }
ECDSAPrivateKey ECDSA private key. never new(ECDSAPrivateKey), use NewECDSAPrivateKey()
func GenerateKey ¶
func GenerateKey(opt int) (*ECDSAPrivateKey, error)
GenerateKey generate a pair of key,input is algorithm type
func (*ECDSAPrivateKey) Bytes ¶
func (key *ECDSAPrivateKey) Bytes() ([]byte, error)
Bytes return key bytes. Inverse method of FromBytes(k []byte, opt AlgorithmOption)
func (*ECDSAPrivateKey) CalculatePublicKey ¶
func (key *ECDSAPrivateKey) CalculatePublicKey() *ECDSAPrivateKey
CalculatePublicKey Calculate the public key contained in the private key when get a ECDSAPrivateKey by FromBytes(...), the public key contained is empty, you should invoke SetPublicKey(...) or CalculatePublicKey(). If you have the Public Key,SetPublicKey(...) is better and faster, since CalculatePublicKey() while calculate public key once again.
func (*ECDSAPrivateKey) FromBytes ¶
func (key *ECDSAPrivateKey) FromBytes(k []byte, opt int) error
FromBytes parse a private Key from bytes, Inverse method of Bytes()
func (*ECDSAPrivateKey) Public ¶
func (key *ECDSAPrivateKey) Public() std.PublicKey
Public GetBig ECDSAPublicKey from a ECDSAPrivateKey, if ECDSAPublicKey is empty, this method will invoke CalculatePublicKey().
func (*ECDSAPrivateKey) SetPublicKey ¶
func (key *ECDSAPrivateKey) SetPublicKey(k *ECDSAPublicKey) *ECDSAPrivateKey
SetPublicKey Set the public key contained in the private key when get a ECDSAPrivateKey by FromBytes(...), the public key contained is empty, you should invoke SetPublicKey(...) or CalculatePublicKey(). If you have the Public Key,SetPublicKey(...) is better and faster, since CalculatePublicKey() while calculate public key once again.
type ECDSAPublicKey ¶
type ECDSAPublicKey struct { elliptic.Curve X, Y *big.Int // contains filtered or unexported fields }
ECDSAPublicKey ECDSA public key. never new(ECDSAPublicKey), use NewECDSAPublicKey()
func (*ECDSAPublicKey) AlgorithmType ¶
func (key *ECDSAPublicKey) AlgorithmType() int
AlgorithmType return the algorithm type
func (*ECDSAPublicKey) Bytes ¶
func (key *ECDSAPublicKey) Bytes() ([]byte, error)
Bytes return key bytes
type ECDSASignature ¶
ECDSASignature ECDSASignature struct