Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Janis Erdmanis committed Aug 31, 2024
1 parent 038d035 commit 374e322
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CryptoSignatures"
uuid = "35cc5888-0c46-470e-89c7-eafcaf79a1aa"
authors = ["Janis Erdmanis <[email protected]>"]
version = "0.3.2"
version = "0.3.3"

[deps]
CryptoGroups = "bc997328-bedd-407e-bcd3-5758e064a52d"
Expand All @@ -10,7 +10,7 @@ Nettle = "49dea1ee-f6fa-5aa6-9a11-8816cee7d4b9"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[compat]
CryptoGroups = "0.4"
CryptoGroups = "0.5"
CryptoPRG = "0.1.0"
Nettle = "1"
julia = "1"
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# CryptoSignatures.jl
[![Build Status](https://travis-ci.com/PeaceFounder/CryptoSignatures.jl.svg?branch=master)](https://travis-ci.com/PeaceFounder/CryptoSignatures.jl)

`CryptoSignatures.jl` aims to be a versatile cryptographic signature library in Julia. Currently supports digital signature algorithm for all available elliptic curves in X9.62 specification. Implementation for modular prime groups is coming shortly.

Expand Down
10 changes: 5 additions & 5 deletions src/CryptoSignatures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module CryptoSignatures
using CryptoGroups: CryptoGroups, generator, concretize_type, octet, order, PGroup
using CryptoGroups.Curves: ECPoint, gx, gy
using CryptoGroups.Specs: MODP, ECP, EC2N, Koblitz, modulus
using CryptoGroups.Utils: octet2int, int2octet, modinv
using CryptoGroups.Utils: octet2int, int2octet

using CryptoPRG: bitlength
using CryptoPRG.Verificatum: PRG
Expand Down Expand Up @@ -99,7 +99,7 @@ function sign(ctx::ECDSAContext, message::Vector{UInt8}, generator::Vector{UInt8
n = order(P)
r =% n

s = modinv(k, n) * (e + key * r) % n
s = invmod(k, n) * (e + key * r) % n

if 1 < r < n - 1 && 1 < s < n - 1
return DSA(r, s)
Expand All @@ -126,7 +126,7 @@ function verify(ctx::ECDSAContext, message::Vector{UInt8}, generator::Vector{UIn
@assert 1 < r < n - 1
@assert 1 < s < n - 1

c = modinv(s, n)
c = invmod(s, n)

u₁ = e*c % n
u₂ = r*c % n
Expand Down Expand Up @@ -190,7 +190,7 @@ function sign(ctx::DSAContext, message::Vector{UInt8}, generator::Vector{UInt8},

r = g^k % q

s = modinv(k, q) * (e + key * r) % q
s = invmod(k, q) * (e + key * r) % q

if 1 < r < q - 1 && 1 < s < q - 1
return DSA(r, s)
Expand Down Expand Up @@ -218,7 +218,7 @@ function verify(ctx::DSAContext, message::Vector{UInt8}, generator::Vector{UInt8
@assert 1 < r < q - 1
@assert 1 < s < q - 1

w = modinv(s, q)
w = invmod(s, q)

u1 = e * w % q
u2 = r * w % q
Expand Down
2 changes: 1 addition & 1 deletion test/degenracy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ for i in 0:255
end


curve = ECP(; p = 23, a = 1, b = 4, n = 29, Gx = 0, Gy = 2)
curve = ECP(; p = 23, a = 1, b = 4, n = 29, cofactor = 1, Gx = 0, Gy = 2)
ctx = ECDSAContext(curve, "sha256")

for i in 0:255
Expand Down
2 changes: 1 addition & 1 deletion test/ec2n.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ curve = EC2N(basis;
b = hex"2E45EF57 1F00786F 67B0081B 9495A3D9 5462F5DE 0AA185EC",
G = hex"04 36B3DAF8 A23206F9 C4F299D7 B21A9C36 9137F2C8 4AE1AA0D 765BE734 33B3F95E 332932E7 0EA245CA 2418EA0E F98018FB",
n = 1569275433846670190958947355803350458831205595451630533029,
h = 2
cofactor = 2
)

ctx = ECDSAContext(curve, "sha1")
Expand Down
2 changes: 1 addition & 1 deletion test/ecp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using CryptoGroups.Utils: @hex_str
curve = ECP(;
p = 6277101735386680763835789423207666416083908700390324961279,
n = 6277101735386680763835789423176059013767194773182842284081,
h = 1,
cofactor = 1,
a = hex"FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE FFFFFFFF FFFFFFFC",
b = hex"64210519 E59C80E7 0FA7E9AB 72243049 FEB8DEEC C146B9B1",
G = hex"03 188DA80E B03090F6 7CBF20EB 43A18800 F4FF0AFD 82FF1012",
Expand Down

0 comments on commit 374e322

Please sign in to comment.