npm install webwallet
webwallet / sdk Goto Github PK
View Code? Open in Web Editor NEWWebWallet SDK for Node
License: MIT License
WebWallet SDK for Node
License: MIT License
After generating the keypair in the src/keypair.js , the keypair.getPublic('hex') encodes the public key using the method getPublic for lib/elliptic/ec/key.js
KeyPair.prototype.getPublic = function getPublic(compact, enc) {
// compact is optional argument
if (typeof compact === 'string') {
enc = compact;
compact = null;
}
if (!this.pub)
this.pub = this.ec.g.mul(this.priv);
if (!enc)
return this.pub;
return this.pub.encode(enc, compact);
};
But in order to be compatible with https://github.com/minkainc/webwallet-sdk-java version it should use the lib/elliptic/eddsa/key.js
KeyPair.prototype.getPublic = function getPublic(enc) {
return utils.encode(this.pubBytes(), enc);
};
So my proposal is to change the implementation of the keypair.js to :
'use strict'
const elliptic = require('elliptic')
const ed25519 = new elliptic.ec('ed25519')
const eddsa = elliptic.eddsa;
const schemes = {
ed25519: {
generate: ({ compressed = false } = {}) => {
let keypair = ed25519.genKeyPair()
let eddsaWithed25519 = new eddsa('ed25519');
let keyPairEddsa = eddsaWithed25519.keyFromSecret(keypair.getPrivate());
return {
scheme: 'ed25519',
public: keyPairEddsa.getPublic('hex'),
secret: keypair.getPrivate('hex')
}
}
}
}
class KeyPair {
static generate(options = {}) {
let {scheme = 'ed25519'} = options
if (!schemes[scheme]) throw new Error('invalid-scheme')
return schemes[scheme].generate(options)
}
}
module.exports = KeyPair
Certainly there are some other changes and adequations that need to be made in Address and Signature.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.