Skip to content

Commit

Permalink
Merge pull request #2 from ChainSafeSystems/license
Browse files Browse the repository at this point in the history
adding license headers
  • Loading branch information
GregTheGreek committed Jan 3, 2019
2 parents e4a58c7 + ecf8281 commit e261454
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
22 changes: 19 additions & 3 deletions src/bls.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
//BLS JS
//Copyright (C) 2018 ChainSafe Systems

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

const CTX = require("../milagro-crypto-js")
const ctx = new CTX("BLS381")
const rand = require("csprng")
Expand Down Expand Up @@ -50,7 +66,7 @@ const hash_string = (m) => {
return hash.digest()
}

// perform H(m) = sha3(m)*G
// perform H(m) = sha3(m)*G
// not sure if this is the correct method to hash to curve
// returns a point on the curve
const hash_to_curve = (m) => {
Expand All @@ -64,7 +80,7 @@ const bls_sign = (k, m) => {
return scalar_mult(hash_to_curve(m), k)
}

// perform e(P, H(m)) == e(G, S) where P is our public key, m is our message, S is
// perform e(P, H(m)) == e(G, S) where P is our public key, m is our message, S is
// our signature, and G is the generator point
const bls_verify = (S, P, m) => {

Expand All @@ -77,4 +93,4 @@ const bls_aggregate = (S_arr, P_arr, m_arr) => {
}


module.exports = {get_rand, gen_key_pair, scalar_mult, scalar_base_mult, add, hash_string, hash_to_curve}
module.exports = {get_rand, gen_key_pair, scalar_mult, scalar_base_mult, add, hash_string, hash_to_curve}
18 changes: 17 additions & 1 deletion src/sign.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
//BLS JS
//Copyright (C) 2018 ChainSafe Systems

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

class public_key {
constructor(k: number) { };
x: number;
Expand All @@ -20,7 +36,7 @@ class field_element {
}

class Signature {
keygen():public_key {
keygen():public_key {
return new public_key(0);
}
}
16 changes: 16 additions & 0 deletions test/test_bls.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
//BLS JS
//Copyright (C) 2018 ChainSafe Systems

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

const bls = require("../src/bls.js")
const CTX = require("../milagro-crypto-js")
const ctx = new CTX("BLS381")
Expand Down

0 comments on commit e261454

Please sign in to comment.