bls12-381 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/README.md +1 -1
- data/lib/bls/pairing.rb +4 -1
- data/lib/bls/point.rb +10 -2
- data/lib/bls/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99316469ec10f56e7547ee00a2496693a9bf637f3671a252481d0cd8db826625
|
4
|
+
data.tar.gz: 58d6687cd394025e3c03981eaf4a12cf1843a859cad20a1b0790caae02027d02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be64b1239722876a9fb0e4c3b0326e90d1fcbf945bb1d3f01e66c468f6213653c7c30b9caa743ac8438d404602bcf5279c7192237362139229615e226949f18b
|
7
|
+
data.tar.gz: 21904be1eb488d0f856a7aeec9b8c5d3275ebd6d6d5be9cd7388d0aeff816f15480136f13498e6ae540dfdca0e3bd6cb7ed6fc941218eaf2b06d781daa1400f2
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-3.
|
1
|
+
ruby-3.1.2
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# BLS12
|
1
|
+
# BLS12-381 for Ruby [](https://github.com/azuchi/bls12-381/actions/workflows/main.yml/badge.svg?branch=main) [](https://badge.fury.io/rb/bls12-381) [](LICENSE)
|
2
2
|
|
3
3
|
This library is a Ruby BLS12-381 implementation based on the JavaScript implementation [noble-bls12-381](https://github.com/paulmillr/noble-bls12-381).
|
4
4
|
|
data/lib/bls/pairing.rb
CHANGED
@@ -7,8 +7,11 @@ module BLS
|
|
7
7
|
# @param [BLS::PointG2] q
|
8
8
|
# @param [Boolean] with_final_exp
|
9
9
|
# @return [BLS::Fq12]
|
10
|
-
# @
|
10
|
+
# @raise [BLS::PairingError] Occur when p.zero? or q.zero?
|
11
|
+
# @raise [ArgumentError]
|
11
12
|
def pairing(p, q, with_final_exp: true)
|
13
|
+
raise ArgumentError, 'p should be BLS::PointG1 object' unless p.is_a?(BLS::PointG1)
|
14
|
+
raise ArgumentError, 'q should be BLS::PointG2 object' unless q.is_a?(BLS::PointG2)
|
12
15
|
raise PairingError, 'No pairings at point of Infinity' if p.zero? || q.zero?
|
13
16
|
|
14
17
|
p.validate!
|
data/lib/bls/point.rb
CHANGED
@@ -101,7 +101,7 @@ module BLS
|
|
101
101
|
alias - subtract
|
102
102
|
|
103
103
|
def multiply_unsafe(scalar)
|
104
|
-
n = scalar.is_a?(
|
104
|
+
n = scalar.is_a?(Field) ? scalar.value : scalar
|
105
105
|
raise PointError, 'Point#multiply: invalid scalar, expected positive integer' if n <= 0
|
106
106
|
|
107
107
|
p = zero
|
@@ -151,7 +151,7 @@ module BLS
|
|
151
151
|
|
152
152
|
# Constant time multiplication. Uses wNAF.
|
153
153
|
def multiply(scalar)
|
154
|
-
n = scalar.is_a?(
|
154
|
+
n = scalar.is_a?(Field) ? scalar.value : scalar
|
155
155
|
raise PointError, 'Invalid scalar, expected positive integer' if n <= 0
|
156
156
|
raise PointError, "Scalar has more bits than maxBits, shouldn't happen" if n.bit_length > max_bits
|
157
157
|
|
@@ -341,6 +341,14 @@ module BLS
|
|
341
341
|
point
|
342
342
|
end
|
343
343
|
|
344
|
+
# Parse Point from private key.
|
345
|
+
# @param [String|Integer] private_key a private key with hex or number.
|
346
|
+
# @return [PointG1] G1Point corresponding to private keys.
|
347
|
+
# @raise [BLS::Error] Occur when the private key is zero.
|
348
|
+
def self.from_private_key(private_key)
|
349
|
+
BASE * BLS.normalize_priv_key(private_key)
|
350
|
+
end
|
351
|
+
|
344
352
|
# Convert hash to PointG2
|
345
353
|
# @param [String] message a hash with hex format.
|
346
354
|
# @return [BLS::PointG2] point.
|
data/lib/bls/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bls12-381
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shigeyuki Azuchi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
86
|
- !ruby/object:Gem::Version
|
87
87
|
version: '0'
|
88
88
|
requirements: []
|
89
|
-
rubygems_version: 3.
|
89
|
+
rubygems_version: 3.3.23
|
90
90
|
signing_key:
|
91
91
|
specification_version: 4
|
92
92
|
summary: BLS12-381 implementation for Ruby.
|