Documentation ¶
Index ¶
- Constants
- Variables
- func FermatInverse(k, P *big.Int) *big.Int
- func GenerateG(G *big.Int, P, J, H *big.Int) (ok bool)
- func GenerateHG(H, G *big.Int, buf []byte, rand io.Reader, P, J *big.Int) (bufOut []byte, err error)
- func GenerateJ(J *big.Int, buf []byte, seed []byte, h hash.Hash, d ParameterSize) (bufNew []byte, ok bool)
- func GenerateKey(priv *PrivateKey, rand io.Reader) error
- func GenerateKeyWithSeed(priv *PrivateKey, rand io.Reader, xkey, upri []byte, sizes ParameterSizes) (xkeyOut, upriOut []byte, err error)
- func GeneratePQ(P, Q *big.Int, buf []byte, J *big.Int, seed []byte, h hash.Hash, ...) (bufNew []byte, count int, ok bool)
- func GenerateParameters(params *Parameters, rand io.Reader, sizes ParameterSizes) (err error)
- func GenerateParametersTTAK(params *Parameters, rand io.Reader, sizes ParameterSizes) (err error)
- func GenerateX(X *big.Int, Q *big.Int, upri, xkey []byte, h hash.Hash, d ParameterSize)
- func GenerateY(Y *big.Int, P, Q, G, X *big.Int)
- func Grow(buf []byte, bytes int) []byte
- func LeftMost(b []byte, bits int) []byte
- func MarshalPrivateKey(key *PrivateKey) ([]byte, error)
- func MarshalPublicKey(pub *PublicKey) ([]byte, error)
- func ReadBigInt(dst *big.Int, rand io.Reader, buf []byte, max *big.Int) (bufNew []byte, err error)
- func ReadBits(dst []byte, rand io.Reader, bits int) ([]byte, error)
- func ReadBytes(dst []byte, rand io.Reader, bytes int) ([]byte, error)
- func RegeneratePQ(ps ParameterSize, J *big.Int, seed []byte, count int) (P, Q *big.Int, ok bool)
- func RegenerateParameters(params *Parameters, rand io.Reader, sizes ParameterSizes) error
- func RightMost(b []byte, bits int) []byte
- func Sign(rand io.Reader, priv *PrivateKey, h Hasher, data []byte) (r, s *big.Int, err error)
- func SignASN1(rand io.Reader, priv *PrivateKey, h Hasher, data []byte) (sig []byte, err error)
- func SignBytes(rand io.Reader, priv *PrivateKey, hashFunc Hasher, data []byte) (sig []byte, err error)
- func Verify(pub *PublicKey, h Hasher, data []byte, r, s *big.Int) bool
- func VerifyASN1(pub *PublicKey, h Hasher, data []byte, sig []byte) bool
- func VerifyBytes(pub *PublicKey, hashFunc Hasher, data, sig []byte) bool
- type GeneratedParameter
- type GenerationParameters
- type Hasher
- type PKCS8Key
- type ParameterSize
- type ParameterSizes
- type Parameters
- type PrivateKey
- type PublicKey
- type SignerOpts
Constants ¶
const NumMRTests = 64
Variables ¶
Functions ¶
func GenerateHG ¶
func GenerateKey ¶
func GenerateKey(priv *PrivateKey, rand io.Reader) error
func GenerateKeyWithSeed ¶
func GenerateKeyWithSeed(priv *PrivateKey, rand io.Reader, xkey, upri []byte, sizes ParameterSizes) (xkeyOut, upriOut []byte, err error)
func GeneratePQ ¶
func GenerateParameters ¶
func GenerateParameters(params *Parameters, rand io.Reader, sizes ParameterSizes) (err error)
Generate the parameters without Key Generation Parameters (J, Seed, Count)
func GenerateParametersTTAK ¶
func GenerateParametersTTAK(params *Parameters, rand io.Reader, sizes ParameterSizes) (err error)
Generate the parameters using Key Generation Parameters (J, Seed, Count)
func ReadBigInt ¶
ReadBigInt returns a uniform random value in [0, max). It panics if max <= 0.
func RegeneratePQ ¶
func RegenerateParameters ¶
func RegenerateParameters(params *Parameters, rand io.Reader, sizes ParameterSizes) error
TTAKParameters -> P, Q, G(randomly)
func SignBytes ¶
func SignBytes(rand io.Reader, priv *PrivateKey, hashFunc Hasher, data []byte) (sig []byte, err error)
Sign data returns the Bytes encoded signature.
func VerifyASN1 ¶
VerifyASN1 verifies the ASN.1 encoded signature, sig, M, of hash using the public key, pub. Its return value records whether the signature is valid.
Types ¶
type GeneratedParameter ¶
type GeneratedParameter struct { P *big.Int Q *big.Int G *big.Int J *big.Int Seed []byte Count int H *big.Int }
func GenerateParametersFast ¶
func GenerateParametersFast(rand io.Reader, d ParameterSize) (generated GeneratedParameter, err error)
type GenerationParameters ¶
func (*GenerationParameters) Equal ¶
func (params *GenerationParameters) Equal(xx GenerationParameters) bool
Equal reports whether p, q, g and sizes have the same value.
func (*GenerationParameters) IsValid ¶
func (params *GenerationParameters) IsValid() bool
type PKCS8Key ¶
type PKCS8Key struct{}
*
- pkcs8 密钥 *
- @create 2024-8-12
- @author deatil
func (PKCS8Key) MarshalPrivateKey ¶
func (this PKCS8Key) MarshalPrivateKey(key *PrivateKey) ([]byte, error)
PKCS8 包装私钥
func (PKCS8Key) MarshalPublicKey ¶
PKCS8 包装公钥
func (PKCS8Key) ParsePrivateKey ¶
func (this PKCS8Key) ParsePrivateKey(der []byte) (key *PrivateKey, err error)
PKCS8 解析私钥
type ParameterSize ¶
func GetSizes ¶
func GetSizes(sizes ParameterSizes) (ParameterSize, bool)
type ParameterSizes ¶
type ParameterSizes int
const ( A2048B224SHA224 ParameterSizes = 1 + iota A2048B224SHA256 A2048B256SHA256 A3072B256SHA256 A1024B160HAS160 )
func (ParameterSizes) Hash ¶
func (ps ParameterSizes) Hash() hash.Hash
type Parameters ¶
type Parameters struct {
P, Q, G *big.Int
GenParameters GenerationParameters
}
func (Parameters) Equal ¶
func (params Parameters) Equal(xx Parameters) bool
Equal reports whether p, q, g and sizes have the same value.
type PrivateKey ¶
PrivateKey represents a KCDSA private key.
func ParsePrivateKey ¶
func ParsePrivateKey(derBytes []byte) (key *PrivateKey, err error)
PKCS8 解析私钥
func (*PrivateKey) Equal ¶
func (priv *PrivateKey) Equal(x crypto.PrivateKey) bool
Equal reports whether priv and x have the same value.
func (*PrivateKey) Public ¶
func (priv *PrivateKey) Public() crypto.PublicKey
Public returns the public key corresponding to priv.
func (*PrivateKey) Sign ¶
func (priv *PrivateKey) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error)
crypto.Signer
type PublicKey ¶
type PublicKey struct { Parameters Y *big.Int }
PublicKey represents a KCDSA public key.
type SignerOpts ¶
type SignerOpts struct {
Hash Hasher
}
SignerOpts contains options for creating and verifying EC-KCDSA signatures.
func (*SignerOpts) GetHash ¶
func (opts *SignerOpts) GetHash() Hasher
GetHash returns func() hash.Hash
func (*SignerOpts) HashFunc ¶
func (opts *SignerOpts) HashFunc() crypto.Hash
HashFunc returns crypto.Hash