Giter Site home page Giter Site logo

stricahq / bip32ed25519 Goto Github PK

View Code? Open in Web Editor NEW
14.0 14.0 12.0 94 KB

Pure javascript implementation of Bip32Ed25519, used for Cardano blockchain key pair.

License: Apache License 2.0

TypeScript 66.19% JavaScript 33.81%
bip32 bip32ed25519 cardano ed25519

bip32ed25519's People

Contributors

ashisherc avatar mahnunchik avatar twwu123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bip32ed25519's Issues

Potential error 0x1f should be 0x7f

Here

xprv[31] &= 0x1f;

If you compare it with classical implementation it should be 0x7f (=127) as per Berstein ref or 0x3f (=63) as per ref10.

See dazoe/ed25519#1 (comment)

for instance, NACL is using 0x7f:
https://github.com/dchest/tweetnacl-js/blob/f1ec050ceae0861f34280e62498b1d3ed9c350c6/nacl.js#L712

I think this error might make the implementation unsecure, as signatures can be malleable. Or do you have any reference justifying such implementation?

SyntaxError: Named export 'Bip32PublicKey' not found

Hello, I've faced with the error in version 1.0.4:

import { Bip32PublicKey } from '@stricahq/bip32ed25519';
         ^^^^^^^^^^^^^^
SyntaxError: Named export 'Bip32PublicKey' not found. The requested module '@stricahq/bip32ed25519' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

Library version 1.0.3 works as expected with named imports.

Workaround:

import bip32ed25519 from '@stricahq/bip32ed25519';
const { Bip32PublicKey } = bip32ed25519;

But it would be helpful to support named imports in module only environment.

does fromEntropy support 24 word seed phrases ?

when i used bip32 from 24 word seed phrase , the same path address is mot match typhonjs wallet address.

```
const words = 'my 24 words';
const rootKey = await Bip32PrivateKey.fromEntropy(words);
// hardened derivation from typhonjs wallet
// m/1852'/1815'/0'/0/0 Payment Key Path 0f9cacda3bc7a196a91c03782c7d2efbd2262f8a5cf2f42146567dd5
// m/1852'/1815'/0'/2/0 Stake Key Path 098d18ebe3d4a859757e86a1ce2c46514c35d4d859a805a109038cb3

const accountKey = rootKey
    .derive(2147483648 + 1852) // purpose
    .derive(2147483648 + 1815) // coin type
    .derive(2147483648 + 0) // account index
    .derive(0) // chain
    .derive(0) // payment key index
    .toPrivateKey();

const stakeKey = rootKey
    .derive(2147483648 + 1852) // purpose
    .derive(2147483648 + 1815) // coin type
    .derive(2147483648 + 0) // account index
    .derive(2) // chain
    .derive(0) // payment key index
    .toPrivateKey();

console.log(accountKey.toPublicKey().hash().toString("hex"));
console.log(stakeKey.toPublicKey().hash().toString("hex"));
// 61cab1cea50fa5b4d7b40269d78e8c0a86485a3ed5484fce7201e8ea
// 2b2c7e8fbc8beac8c620298d3e92e6b195b2cdb77f384498e17ab4b3

const paymentCred0 = {
    hash: accountKey.toPublicKey().hash().toString("hex"),
    type: typhonJs.types.HashType.ADDRESS,
};
const paymentCred1 = {
    hash: stakeKey.toPublicKey().hash().toString("hex"),
    type: typhonJs.types.HashType.ADDRESS,
};
const address1 = new typhonJs.address.BaseAddress(
    typhonJs.types.NetworkId.MAINNET,
    paymentCred0,
    paymentCred1
);
console.log(address1);
// address1 : addr1q9su4vww5586tdxhkspxn4uw3s9gvjz68m25sn7wwgq7363t93lgl0ytatyvvgpf35lf9e43jkevmdml8pzf3ct6kjesj4al6c
// typhonjs wallet address : addr1qy8eetx680r6r94frsphstra9maayf303fw09appget8m4gf35vwhc754pvh2l5x588zc3j3fs6afkze4qz6zzgr3jesr4gp3k

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.