Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
backend: change our key derivation path
Browse files Browse the repository at this point in the history
  • Loading branch information
burdiyan committed Jun 12, 2024
1 parent bc757d6 commit ecfd0e4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
10 changes: 6 additions & 4 deletions backend/core/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ func AccountFromMnemonic(m []string, passphrase string) (KeyPair, error) {
return AccountFromSeed(seed)
}

// AccountDerivationPath value according to SLIP-10 and BIP-44.
// 109116116 is the concatenation of Unicode code point values for letters mtt - stands for Mintter.
const AccountDerivationPath = "m/44'/109116116'/0'"
// keyDerivationPath value according to SLIP-10 and BIP-44.
// 104109 is the concatenation of Unicode code point values for 'hm' - stands for Hypermedia.
// The first zero segment can be incremented to derive multiple accounts eventually.
// PR to add our derivation code to SLIP-44: https://github.com/satoshilabs/slips/pull/1742.
const keyDerivationPath = "m/44'/104109'/0'/0/0"

// AccountFromSeed creates an account key pair from a previously generated entropy.
func AccountFromSeed(rand []byte) (KeyPair, error) {
slipSeed, err := slip10.DeriveForPath(AccountDerivationPath, rand)
slipSeed, err := slip10.DeriveForPath(keyDerivationPath, rand)
if err != nil {
return KeyPair{}, err
}
Expand Down
2 changes: 1 addition & 1 deletion backend/core/identity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func TestSLIP10Derivation(t *testing.T) {
seed, err := hex.DecodeString("000102030405060708090a0b0c0d0e0f")
require.NoError(t, err)

k, err := slip10.DeriveForPath(AccountDerivationPath, seed)
k, err := slip10.DeriveForPath(keyDerivationPath, seed)
require.NoError(t, err)

require.Equal(t, "6dba7f7e7d2e1e51072c601e2e35cdd7025cea3978c4ecc54068b84f0f666a40", hex.EncodeToString(k.Seed()))
Expand Down
7 changes: 6 additions & 1 deletion backend/mttnet/mttnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ import (

const protocolSupportKey = "mintter-support" // This is what we use as a key to protect the connection in ConnManager.

const (
protocolPrefix = "/hypermedia/"
protocolVersion = "0.4.0"
)

var userAgent = "mintter/<dev>"

// GatewayClient is the bridge to talk to the gateway.
Expand Down Expand Up @@ -160,7 +165,7 @@ func New(cfg config.P2P, db *sqlitex.Pool, blobs *hyper.Storage, me core.Identit
testnetSuffix = "-" + cfg.TestnetName
}

protoInfo := newProtocolInfo("/hypermedia/", "0.3.0"+testnetSuffix)
protoInfo := newProtocolInfo(protocolPrefix, protocolVersion+testnetSuffix)

client := newClient(me, host, protoInfo.ID)
clean.Add(client)
Expand Down

0 comments on commit ecfd0e4

Please sign in to comment.