How to use ed25519 - 10 common examples

To help you get started, we’ve selected a few ed25519 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github abedinpour / HAS / src / config.ts View on Github external
private writeConfig() {
        // Generate Ed25519 Keys
        if (!this.publicKey || !this.privateKey) {
            const seed = crypto.randomBytes(32);
            const keyPair = Ed25519.MakeKeypair(seed);
            this.publicKey = keyPair.publicKey;
            this.privateKey = keyPair.privateKey;
        }

        FS.writeFileSync(this.configDir, JSON.stringify({
            CCN: this.CCN,
            pairings: this.pairings,
            publicKey: this.publicKey.toString('hex'),
            privateKey: this.privateKey.toString('hex'),
            UUIDMap: this.UUIDMap
        }), 'utf8');
    }
github LiskHQ / lisk-sdk / modules / contacts.js View on Github external
}, function (err) {
		if (err) {
			return cb(err[0].message);
		}

		var hash = crypto.createHash('sha256').update(body.secret, 'utf8').digest();
		var keypair = ed.MakeKeypair(hash);

		if (body.publicKey) {
			if (keypair.publicKey.toString('hex') != body.publicKey) {
				return cb("Invalid passphrase");
			}
		}

		var query = {};

		var followingAddress = body.following.substring(1, body.following.length);
		var isAddress = /^[0-9]+[L|l]$/g;
		if (isAddress.test(followingAddress)) {
			query.address = followingAddress;
		} else {
			query.username = followingAddress;
		}
github ddnlink / ddn / packages / ddn-peer / src / network / service / api / multisignatures / index.js View on Github external
throw new Error(validateErrors[0].message);
        }

        var transaction = await this.runtime.transaction.getUnconfirmedTransaction(body.transactionId);
        if (!transaction) {
            throw new Error("Transaction not found");
        }

        if (body.publicKey) {
            if (keypair.publicKey.toString('hex') != body.publicKey) {
                throw new Error("Invalid passphrase");
            }
        }

        var hash = crypto.createHash('sha256').update(body.secret, 'utf8').digest();
        var keypair = ed.MakeKeypair(hash);

        var sign = await this.runtime.transaction.multisign(keypair, transaction);

        if (transaction.type == AssetTypes.MULTISIGNATURE) {
            if ((transaction.asset.multisignature.keysgroup.indexOf(`+${keypair.publicKey.toString('hex')}`) == -1) ||
                (transaction.signatures && transaction.signatures.indexOf(sign.toString('hex')) != -1)) {
                throw new Error("Permission to sign transaction denied");
            }

            setImmediate(async() => {
                try
                {
                    await this.runtime.socketio.emit('multisignatures/singature/change', {});
                }
                catch (err)
                {
github KhaosT / HAP-NodeJS / Accessory.js View on Github external
function AccessoryInfo(displayName,username, pincode) {
	if (!(this instanceof AccessoryInfo))  {
		return new AccessoryInfo(displayName,username);
	}
	this.displayName = displayName;
	this.username = username;
	this.pincode = pincode;

	var seed = crypto.randomBytes(32);
	var keyPair = ed25519.MakeKeypair(seed);
	this.keyPair = {
		signSk: keyPair.privateKey,
		signPk: keyPair.publicKey,
		paired: false
	};
}
github abedinpour / HAS / src / config.js View on Github external
Config.prototype.writeConfig = function () {
        if (!this.publicKey || !this.privateKey) {
            var seed = crypto.randomBytes(32);
            var keyPair = Ed25519.MakeKeypair(seed);
            this.publicKey = keyPair.publicKey;
            this.privateKey = keyPair.privateKey;
        }
        FS.writeFileSync(this.configDir, JSON.stringify({
            CCN: this.CCN,
            pairings: this.pairings,
            publicKey: this.publicKey.toString('hex'),
            privateKey: this.privateKey.toString('hex'),
            UUIDMap: this.UUIDMap
        }), 'utf8');
    };
    Config.prototype.setServer = function (server) {
github sprut666666 / com.sprut.homekit / node_modules / has-node / src / config.js View on Github external
Config.prototype.writeConfig = function () {
        if (!this.publicKey || !this.privateKey) {
            var seed = crypto.randomBytes(32);
            var keyPair = Ed25519.MakeKeypair(seed);
            this.publicKey = keyPair.publicKey;
            this.privateKey = keyPair.privateKey;
        }
        FS.writeFileSync(this.configDir, JSON.stringify({
            CCN: this.CCN,
            pairings: this.pairings,
            publicKey: this.publicKey.toString('hex'),
            privateKey: this.privateKey.toString('hex'),
            UUIDMap: this.UUIDMap
        }), 'utf8');
    };
    Config.prototype.setServer = function (server) {
github grover / homebridge-ranger / src / hap / pairing / PairSetup.js View on Github external
getM5Request() {

    const seed = crypto.randomBytes(32);
    const keyPair = ed25519.MakeKeypair(seed);
    this._rangerPairingID = Buffer.from(uuid());
    this._rangerLTSK = keyPair.privateKey;
    this._rangerLTPK = keyPair.publicKey;

    this._srpSharedSecret = this._srp.computeK();
    const controllerSalt = Buffer.from("Pair-Setup-Controller-Sign-Salt");
    const controllerInfo = Buffer.from("Pair-Setup-Controller-Sign-Info");
    const iOSDeviceX = hkdf("sha512", controllerSalt, this._srpSharedSecret, controllerInfo, 32);

    const iOSDeviceInfo = Buffer.concat([iOSDeviceX, this._rangerPairingID, this._rangerLTPK]);

    const iOSDeviceSignature = ed25519.Sign(iOSDeviceInfo, this._rangerLTSK);

    let subtlv = {};
    subtlv[TLVType.Identifier] = this._rangerPairingID;
    subtlv[TLVType.PublicKey] = this._rangerLTPK;
github LiskHQ / lisk-sdk / modules / contacts.js View on Github external
if (requester.publicKey == account.publicKey) {
							return cb("Incorrect requester");
						}

						if (!following) {
							return cb("Username not found");
						}

						followingAddress = body.following[0] + following.address;

						var secondKeypair = null;

						if (requester.secondSignature) {
							var secondHash = crypto.createHash('sha256').update(body.secondSecret, 'utf8').digest();
							secondKeypair = ed.MakeKeypair(secondHash);
						}

						try {
							var transaction = library.logic.transaction.create({
								type: TransactionTypes.FOLLOW,
								sender: account,
								keypair: keypair,
								secondKeypair: secondKeypair,
								contactAddress: followingAddress,
								requester: keypair
							});
						} catch (e) {
							return cb(e.toString());
						}
						modules.transactions.receiveTransactions([transaction], cb);
					});
github AschPlatform / asch / src / accounts.js View on Github external
if (err) {
            return cb(err.toString());
          }
          if (!account || !account.publicKey) {
            return cb("Account not found");
          }

          if (account.secondSignature && !body.secondSecret) {
            return cb("Invalid second passphrase");
          }

          var secondKeypair = null;

          if (account.secondSignature) {
            var secondHash = crypto.createHash('sha256').update(body.secondSecret, 'utf8').digest();
            secondKeypair = ed.MakeKeypair(secondHash);
          }

          try {
            var transaction = library.base.transaction.create({
              type: TransactionTypes.VOTE,
              votes: body.delegates,
              sender: account,
              keypair: keypair,
              secondKeypair: secondKeypair
            });
          } catch (e) {
            return cb(e.toString());
          }
          modules.transactions.receiveTransactions([transaction], cb);
        });
      }
github AschPlatform / asch / src / multisignatures.js View on Github external
if (err) {
          return cb(err.toString());
        }
        if (!account || !account.publicKey) {
          return cb("Account not found");
        }

        if (account.secondSignature && !body.secondSecret) {
          return cb("Invalid second passphrase");
        }

        var secondKeypair = null;

        if (account.secondSignature) {
          var secondHash = crypto.createHash('sha256').update(body.secondSecret, 'utf8').digest();
          secondKeypair = ed.MakeKeypair(secondHash);
        }

        try {
          var transaction = library.base.transaction.create({
            type: TransactionTypes.MULTI,
            sender: account,
            keypair: keypair,
            secondKeypair: secondKeypair,
            min: body.min,
            keysgroup: body.keysgroup,
            lifetime: body.lifetime
          });
        } catch (e) {
          return cb(e.toString());
        }

ed25519

An Ed25519 elliptic-curve cryptography implementation for Node.js

BSD-2-Clause
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular ed25519 functions