Skip to content

Commit

Permalink
Update doc and upgrade version
Browse files Browse the repository at this point in the history
  • Loading branch information
lishawnl committed Apr 14, 2024
1 parent f9b1d15 commit 077fd16
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v1.0.2

* Adds support for Solana addresses

## v1.0.1

* Brings in Ethereum EIP-55 checksum addresses, credit goes to @wchenNL
Expand Down
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Build Status](https://travis-ci.com/AgileAlpha/block_keys.svg?branch=master)](https://travis-ci.com/AgileAlpha/block_keys)

BlockKeys is an Elixir implementation of BIP44 Multi-Account Hierarchy for Deterministic Wallets.
Currently it supports Bitcoin and Ethereum but will be extended to support a [large number of coin types](https://github.com/satoshilabs/slips/blob/master/slip-0044.md) of coins in the future.
Currently it supports Bitcoin, Ethereum and Solana, but will be extended to support a [large number of coin types](https://github.com/satoshilabs/slips/blob/master/slip-0044.md) of coins in the future.

For low level details check the [Wiki](https://github.com/AgileAlpha/block_keys/wiki).

Expand All @@ -14,7 +14,7 @@ Add the dependency to your `mix.exs`:
```
def deps do
[
{:block_keys, "~> 1.0.1"}
{:block_keys, "~> 1.0.2"}
]
end
```
Expand Down Expand Up @@ -100,6 +100,13 @@ path = "M/60'/0'/0'"
xpub = BlockKeys.CKD.derive(root_key, path)
```

### Solana

```
path = "M/501'/0'/0'"
xpub = BlockKeys.CKD.derive(root_key, path, network: :solana)
```

## Generating addresses from Master Public Key

Generally you would export the master public key and keep it on your live server so that you can generate addresses for payments or deposits.
Expand All @@ -120,6 +127,13 @@ path = "M/0/0"
address = BlockKeys.Ethereum.address(xpub, path)
```

### Solana

```
path = "M/0/0"
address = BlockKeys.Solana.address(xpub, path)
```

## Path and derivations

You will notice that we used different paths for generating the master private key vs addresses. This is because our initial derivation path includes some hardened paths in order to prevent any downstream generation of addresses for specific paths. For example, the coin code path is hardened in order to prevent anyone from generating a tree of addresses for a different coin given our master public key.
Expand Down
1 change: 1 addition & 0 deletions lib/block_keys/solana/address.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ defmodule BlockKeys.Solana.Address do
|> Base58.encode()
end

# https://solanacookbook.com/references/keypairs-and-wallets.html#how-to-check-if-a-public-key-has-an-associated-private-key
def valid_address?(address) when byte_size(address) in 32..44 do
public_key = address |> BlockKeys.Base58.decode() |> :binary.encode_unsigned()
Ed25519.on_curve?(public_key)
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule BlockKeys.MixProject do
def project do
[
app: :block_keys,
version: "1.0.1",
version: "1.0.2",
elixir: "~> 1.7",
description: description(),
start_permanent: Mix.env() == :prod,
Expand Down

0 comments on commit 077fd16

Please sign in to comment.