bip32

package
v0.0.0-...-ff9824d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package bip32 implements the various screwed up legacy Oasis variants of BIP32-Ed25519.

Index

Constants

View Source
const (
	// HardenedIndexOffset is the offset added to derivation indexes to indicate
	// that the hardened formula should be used.
	HardenedIndexOffset = 1 << 31
)

Variables

View Source
var (
	// ErrDivisibleByBaseOrder is the error returned when the derived child
	// is a multiple of the scalar group order.
	ErrDivisibleByBaseOrder = errors.New("bip32: kL divisible by basepoint order")
)

Functions

func ScalarToPublicKey

func ScalarToPublicKey(rawScalar []byte) (ed25519.PublicKey, error)

ScalarToPublicKey converts a scalar to a public key.

Types

type Node

type Node struct {
	// contains filtered or unexported fields
}

Node is a HKD derivation node.

func NewBitpieRoot

func NewBitpieRoot(seed []byte) (*Node, error)

func NewLedgerRoot

func NewLedgerRoot(seed []byte) (*Node, error)

NewLedgerRoot returns the root (master) node, corresponding to the provided seed, using the fucked up Ledger BIP32-Ed25519 variant.

func NewRoot

func NewRoot(seed []byte) (*Node, error)

NewRoot returns the root (master) node, corresponding to the provided seed.

func (*Node) DeriveChild

func (n *Node) DeriveChild(idx uint32) (*Node, error)

DeriveChild derives a sub-key with the provided index.

func (*Node) DerivePath

func (n *Node) DerivePath(path string) (*Node, error)

DerivePath derives the node associated with a path.

func (*Node) GetBitpiePrivateKey

func (n *Node) GetBitpiePrivateKey() ed25519.PrivateKey

GetBitpiePrivateKey returns the Oasis network private key associated with a node, derived using the Bitpie method.

Just use Ristretto, but using kL as the RFC 8032 seeds is marginally less bad than BIP-Ed25519.

func (*Node) GetExtendedPrivateKey

func (n *Node) GetExtendedPrivateKey() []byte

GetExtendedPrivateKey returns the Oasis network private key associated with a node, in the BIP-Ed25519 extended format.

func (*Node) GetLedgerPrivateKey

func (n *Node) GetLedgerPrivateKey() ed25519.PrivateKey

GetLedgerPrivateKey returns the Oasis network private key associated with a node, derived using the legacy Ledger method.

Just use Ristretto, but using kL as the RFC 8032 seeds is marginally less bad than BIP-Ed25519.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL