Documentation ¶
Index ¶
- Constants
- Variables
- func CreateKeyPair(b []byte) (PublicKey, SecretKey, error)
- func GenerateRandomKeyPair() (PublicKey, SecretKey, error)
- func RecoverKeyPairFromClassicalSeed(seed string, i uint32) (PublicKey, SecretKey, error)
- func RecoverKeyPairFromCoinSeed(seed CoinSeed, i uint32) (PublicKey, SecretKey, error)
- type Address
- func (addr Address) GetChecksum() ([]byte, error)
- func (addr Address) GetPrefix() string
- func (addr Address) GetPublicKey() (PublicKey, error)
- func (addr Address) IsCorrectlyFormatted() bool
- func (addr Address) IsValid() bool
- func (d *Address) MarshalJSON() ([]byte, error)
- func (addr Address) RemovePrefix() Address
- func (d *Address) UnmarshalJSON(data []byte) (err error)
- func (addr Address) UpdatePrefix() Address
- type CoinSeed
- type Currency
- type PublicKey
- func (pk PublicKey) CompareChecksum(checksum []byte) bool
- func (pk PublicKey) CompareSignature(message, sig []byte) bool
- func (pk *PublicKey) CreateAddress() Address
- func (pk PublicKey) CreateChecksum() []byte
- func (d PublicKey) MarshalJSON() ([]byte, error)
- func (d *PublicKey) UnmarshalJSON(data []byte) (err error)
- type SecretKey
- type Seed
- type SeedFY
Constants ¶
const ADDRESS_PREFIX = "xrb"
Variables ¶
var ALLOWED_PREFIX = [...]string{"xrb"}
var ErrImpossibleDecode = errors.New("impossible to decode the seed")
var SupportedVersions = [...]uint8{0}
Functions ¶
func CreateKeyPair ¶
CreateKeyPair creates the Ed25519 key-pair from an given input and returns the public/private key, and error not nil if something go wrong.
func GenerateRandomKeyPair ¶
GenerateRandomKeyPair creates the Ed25519, using an random input, we use the crypto/rand.
func RecoverKeyPairFromClassicalSeed ¶
RecoverKeyPairFromClassicalSeed will return the Ed25519 key-pair based on the hex-encoded HEX and one INDEX it uses the same process used in official wallet of Nano. In case of failure the error will be non-nil. The Nano Wallet Seed uses BLAKE2b(size = 32, key = nil, message = SEED+INDEX) to construct the key.
func RecoverKeyPairFromCoinSeed ¶
RecoverKeyPairFromSeed will return the Ed25519 key-pair based on given COINSEED and INDEX, it also returns non-nil error in case of failure. It uses the Blake2X instead of Blake2b and can support up to 256 keys. The Nanollet Seed uses BLAKE2bXOF(size = COINSIZE, key = COINSEED, message = INDEX)
Types ¶
type Address ¶
type Address string
func (Address) GetChecksum ¶
GetChecksum extract the existing checksum of the address, returns the checksum as byte-array.
func (Address) GetPrefix ¶
GetPrefix extract the existing prefix of the address, everything before the first underscore.
func (Address) GetPublicKey ¶
PublicKeyFromFromAddress gets the Ed25519 public-key from the encoded address, returning the public-key. It's return an non-nil error if something bad happens.
func (Address) IsCorrectlyFormatted ¶
IsCorrectlyFormatted returns true if the given encoded address have an correct format. It return true if had an valid prefix and length, but checksum doesn't matter.
func (Address) IsValid ¶
IsValid returns true if the given encoded address have an correct formatting and also the checksum is correct.
func (*Address) MarshalJSON ¶
func (Address) RemovePrefix ¶
RemovePrefix remove the prefix of the address, returns an address without the prefix.
func (*Address) UnmarshalJSON ¶
func (Address) UpdatePrefix ¶
UpdateAddress modify the prefix of the address returning the address with new prefix identifier. (Can be used if "xrb_" be replaced by "nano_" in future)
type CoinSeed ¶
type CoinSeed []byte
func RecoverCoinSeed ¶
RecoverKeyPairFromSeed will return an seed for given currency.
type PublicKey ¶
type PublicKey []byte
func (PublicKey) CompareChecksum ¶
CompareChecksum check the publick-key with arbitrary given checksum, it will return true if the checksum matches and false otherwise.
func (PublicKey) CompareSignature ¶
CompareSignature checks the autencity of the signature based on public-key, it returns false if is wrong.
func (*PublicKey) CreateAddress ¶
CreateAddress creates the encoded address using the public-key. It returns the address (with identifier, public-key and checksum) as string, encoded with base32.
func (PublicKey) CreateChecksum ¶
Checksum creates the checksum for given public-key, it returns the checksum in byte format.
func (PublicKey) MarshalJSON ¶
func (*PublicKey) UnmarshalJSON ¶
type SecretKey ¶
type SecretKey []byte
func (SecretKey) CreateSignature ¶
CreateSignature signs the message with the private-key. It return the signature.
type SeedFY ¶
func NewSeedFY ¶
NewSeedFY generate the SeedFY, which is the random salt and the default computational cost parameters used in the Argon2id derivation in combination with the password.
func ReadSeedFY ¶
ReadSeedFY act like to NewSeedFY, however it creates the struct based on the given hex-encoded SeedFY.