Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bitagora-booth

Package Overview
Dependencies
Maintainers
1
Versions
178
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitagora-booth - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

33

booth.js

@@ -1,2 +0,2 @@

const bitagoraVersion = '1.0.8';
const bitagoraVersion = '1.0.9';
const CryptoJS = require('crypto-js');

@@ -43,3 +43,3 @@ const Ecdsa = require('elliptic');

this.ballot = 'ffff' + ballot + 'ffff'; /* 5 bytes with padding "\xFFFF" + "\x00" or "\x01" + "\xFFFF" */
this.checkSum = CryptoJS.SHA256(this.id + this.idPartial + this.poll + this.date + this.questions + this.options + emptyBallot() ).toString().substr(0,4); /* 2 bytes double SHA256 of previous bytes */
this.checkSum = CryptoJS.SHA256(this.version + this.id + this.idPartial + this.poll + this.date + this.questions + this.options + emptyBallot() ).toString().substr(0,4); /* 2 bytes double SHA256 of previous bytes */

@@ -136,3 +136,3 @@ this.certTag = 'f2'; /* 1 byte "\x02" indicating beginning of server signature/pubkey */

function getPublicToken(vote) {
return ( vote.version + vote.id + vote.idPartial + vote.poll + vote.date + vote.questions + vote.options + emptyBallot() + vote.checkSum );
return ( vote.version + vote.id + vote.idPartial + vote.poll + vote.date + vote.questions + vote.options + emptyBallot() + vote.checkSum + vote.voterKey);
}

@@ -151,4 +151,8 @@

function validateCertSig(vote) {
var key = EC.keyFromPublic(vote.certKey, 'hex');
var payload = getPublicToken(vote) + vote.voterKey;
var pubPoint = EC.keyFromPublic(vote.certKey, 'hex').getPublic();
var x = pubPoint.getX().toString('hex');
var y = pubPoint.getY().toString('hex');
var pub = "04" + x + y;
var key = EC.keyFromPublic(pub, 'hex');
var payload = getPublicToken(vote);
var certScript = CryptoJS.SHA256(CryptoJS.SHA256(payload)).toString();

@@ -175,3 +179,3 @@ return key.verify(certScript, vote.certSig);

console.log("Validating vote");
console.log("Ballot");
var options = vote.options.replace(/a/g, '').match(/.{2}/g);

@@ -195,3 +199,3 @@ console.log(options);

console.log("Checksum");
var voteString = vote.versionByte + vote.id + vote.idPartial + vote.poll + vote.date + vote.questions + vote.options + emptyBallot();
var voteString = vote.version + vote.id + vote.idPartial + vote.poll + vote.date + vote.questions + vote.options + emptyBallot();
var checksum = CryptoJS.SHA256(voteString).toString().substr(0,4);

@@ -202,3 +206,3 @@ if (checksum != vote.checkSum) {

}
console.log("Certsig");
if (!validateCertSig(vote)) {

@@ -208,3 +212,3 @@ console.log('Invalid certifier signature');

}
console.log("SigVote");
if (!validateVoterSig(vote)) {

@@ -248,10 +252,9 @@ console.log('Invalid voter signature');

var signature = signScript(newVoteScript, privkey_hex);
var pubkey = EC.keyFromPrivate(privkey_hex, 'hex').getPublic(true, 'hex');
if (signature) {
newVote = completeVote(newVote, data.idToken, data.userId, signature, pubkey, ctx);
console.log('Completed vote: ' + JSON.stringify(newVote));
console.log('Completed vote hex: ' + getVoteHex(newVote));
var pubkey_hex = EC.keyFromPrivate(privkey_hex, 'hex').getPublic(true, 'hex');
if (signature && pubkey_hex != null) {
newVote = completeVote(newVote, data.idToken, data.userId, signature, pubkey_hex, ctx);
if (validateVote(newVote)) {
console.log('Vote is valid');
return JSON.stringify(newVoteScript);
console.log(getVoteHex(newVote));
return getVoteHex(newVote);
} else {

@@ -258,0 +261,0 @@ console.log('Vote is not valid');

{
"name": "bitagora-booth",
"version": "1.0.8",
"version": "1.0.9",
"description": "Bitagora booth js functions",

@@ -5,0 +5,0 @@ "main": "booth.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc