Categorygithub.com/neatlib/crypto-go
modulepackage
1.2.0
Repository: https://github.com/neatlib/crypto-go.git
Documentation: pkg.go.dev

# README

Crypto Go Library

# Packages

No description provided by the author
No description provided by the author

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
This uses the OS and the Seed(s).
RandHex(24) gives 96 bits of randomness, strong enough for most purposes.
Returns a crand.Reader mixed with user-supplied entropy.
No description provided by the author
secret must be 32 bytes long.
No description provided by the author
secret must be 32 bytes long.
No description provided by the author
NOTE: secret should be the output of a KDF like bcrypt, if it's derived from user input.
No description provided by the author
NOTE: secret should be the output of a KDF like bcrypt, if it's derived from user input.
Mix additional bytes of randomness, e.g.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

Types of implementations.
Types of implementations.
Types of implementations.
Types of implementations.
Types of implementations.
Types of implementations.
Types of implementations.
Types of implementations.

# Structs

PrivKeyS add json serialization to PrivKey.
PubKeyS add json serialization to PubKey.
SignatureS add json serialization to Signature.

# Interfaces

PrivKey is part of PrivAccount and state.PrivValidator.
PubKey is part of Account and Validator.
Signature is a part of Txs and consensus Votes.

# Type aliases

No description provided by the author
//------------------------------------- // Implements PubKey.
//------------------------------------- // Implements Signature type BLSSignature []byte func CreateBLSSignature() BLSSignature { pubKey := pairing.NewG2().Rand() return pubKey.Bytes() } func (sig BLSSignature) getElement() *pbc.Element { return pairing.NewG2().SetBytes(sig) } func (sig BLSSignature) GetElement() *pbc.Element { return pairing.NewG2().SetBytes(sig) } func (sig BLSSignature) Set1() { copy(sig, pairing.NewG1().Set1().Bytes()) } func BLSSignatureMul(l, r Signature) Signature { lSign,lok := l.(BLSSignature); rSign, rok := r.(BLSSignature); if lok&&rok { el1 := lSign.getElement() el2 := rSign.getElement() rs := pairing.NewG2().Mul(el1, el2) return BLSSignature(rs.Bytes()) } else { return nil } } func (sig BLSSignature) Mul(other Signature) bool { if otherSign,ok := other.(BLSSignature); ok { el1 := sig.getElement() fmt.Println(el1.Bytes()[:3]) el2 := otherSign.getElement() fmt.Println(el2.Bytes()[:3]) rs := el1.Mul(el1, el2) fmt.Println("el1",el1.Bytes()[:3]) fmt.Println("rs", rs.Bytes()[:3]) copy(sig, rs.Bytes()) return true } else { return false } } func (sig BLSSignature) MulWithSet1(other Signature) bool { if otherSign,ok := other.(BLSSignature); ok { el1 := sig.getElement() el1.Set1() fmt.Println(el1.Bytes()[:3]) el2 := otherSign.getElement() fmt.Println(el2.Bytes()[:3]) rs := el1.Mul(el1, el2) fmt.Println("el1",el1.Bytes()[:3]) fmt.Println("rs", rs.Bytes()[:3]) copy(sig, rs.Bytes()) return true } else { return false } } func (sig BLSSignature) Bytes() []byte { return sig } func (sig BLSSignature) IsZero() bool { return len(sig) == 0 } func (sig BLSSignature) String() string { return fmt.Sprintf("/%X.../", Fingerprint(sig)) } func (sig BLSSignature) Equals(other Signature) bool { if otherBLS, ok := other.(BLSSignature); ok { return sig.getElement().Equals(otherBLS.getElement()) } else { return false } } func (p BLSSignature) MarshalJSON() ([]byte, error) { return data.Encoder.Marshal(p) } func (p *BLSSignature) UnmarshalJSON(enc []byte) error { var ref []byte err := data.Encoder.Unmarshal(&ref, enc) copy(*p, ref) return err } */.
No description provided by the author
No description provided by the author
No description provided by the author
Implements PrivKey.
Implements PrivKey.
Implements PubKey.
Implements PubKey.
Implements Signature.
Implements Signature.