fix: resolve exported type stuttering issues (revive)
- Rename VaultMetadata to Metadata in internal/vault package to avoid stuttering - Rename BIP85DRNG to DRNG in pkg/bip85 package to avoid stuttering - Update all references in code and tests
This commit is contained in:
@@ -54,6 +54,7 @@ func IdentityFromEntropy(ent []byte) (*age.X25519Identity, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("bech32 encode: %w", err)
|
||||
}
|
||||
|
||||
return age.ParseX25519Identity(strings.ToUpper(s))
|
||||
}
|
||||
|
||||
@@ -125,6 +126,7 @@ func DeriveIdentity(mnemonic string, n uint32) (*age.X25519Identity, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return IdentityFromEntropy(ent)
|
||||
}
|
||||
|
||||
@@ -135,5 +137,6 @@ func DeriveIdentityFromXPRV(xprv string, n uint32) (*age.X25519Identity, error)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return IdentityFromEntropy(ent)
|
||||
}
|
||||
|
||||
@@ -393,6 +393,7 @@ func TestIdentityFromEntropyEdgeCases(t *testing.T) {
|
||||
err,
|
||||
) // In test context, panic is acceptable for setup failures
|
||||
}
|
||||
|
||||
return b
|
||||
}(),
|
||||
expectError: false,
|
||||
|
||||
@@ -45,29 +45,29 @@ var (
|
||||
TestNetPrivateKey = []byte{0x04, 0x35, 0x83, 0x94}
|
||||
)
|
||||
|
||||
// BIP85DRNG is a deterministic random number generator seeded by BIP85 entropy
|
||||
type BIP85DRNG struct {
|
||||
// DRNG is a deterministic random number generator seeded by BIP85 entropy
|
||||
type DRNG struct {
|
||||
shake io.Reader
|
||||
}
|
||||
|
||||
// NewBIP85DRNG creates a new DRNG seeded with BIP85 entropy
|
||||
func NewBIP85DRNG(entropy []byte) *BIP85DRNG {
|
||||
func NewBIP85DRNG(entropy []byte) *DRNG {
|
||||
// The entropy must be exactly 64 bytes (512 bits)
|
||||
if len(entropy) != 64 {
|
||||
panic("BIP85DRNG entropy must be 64 bytes")
|
||||
panic("DRNG entropy must be 64 bytes")
|
||||
}
|
||||
|
||||
// Initialize SHAKE256 with the entropy
|
||||
shake := sha3.NewShake256()
|
||||
shake.Write(entropy)
|
||||
|
||||
return &BIP85DRNG{
|
||||
return &DRNG{
|
||||
shake: shake,
|
||||
}
|
||||
}
|
||||
|
||||
// Read implements the io.Reader interface
|
||||
func (d *BIP85DRNG) Read(p []byte) (n int, err error) {
|
||||
func (d *DRNG) Read(p []byte) (n int, err error) {
|
||||
return d.shake.Read(p)
|
||||
}
|
||||
|
||||
@@ -266,6 +266,7 @@ func DeriveXPRV(masterKey *hdkeychain.ExtendedKey, index uint32) (*hdkeychain.Ex
|
||||
func doubleSHA256(data []byte) []byte {
|
||||
hash1 := sha256.Sum256(data)
|
||||
hash2 := sha256.Sum256(hash1[:])
|
||||
|
||||
return hash2[:]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user