| ... | @@ -1,3 +1,4 @@ | ... | @@ -1,3 +1,4 @@ |
| | 1 | const builtin = @import("builtin"); |
| 1 | const std = @import("std"); | 2 | const std = @import("std"); |
| 2 | const fmt = std.fmt; | 3 | const fmt = std.fmt; |
| 3 | const testing = std.testing; | 4 | const testing = std.testing; |
| ... | @@ -7,6 +8,8 @@ const Secp256k1 = @import("../secp256k1.zig").Secp256k1; | ... | @@ -7,6 +8,8 @@ const Secp256k1 = @import("../secp256k1.zig").Secp256k1; |
| 7 | const lambda: u256 = 0x5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72; | 8 | const lambda: u256 = 0x5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72; |
| 8 | | 9 | |
| 9 | test "secp256k1 ECDH key exchange" { | 10 | test "secp256k1 ECDH key exchange" { |
| | 11 | if (builtin.zig_backend == .stage2_llvm and builtin.target.cpu.arch.isPowerpc64()) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/37121 |
| | 12 | |
| 10 | const io = testing.io; | 13 | const io = testing.io; |
| 11 | const dha = Secp256k1.scalar.random(io, .little); | 14 | const dha = Secp256k1.scalar.random(io, .little); |
| 12 | const dhb = Secp256k1.scalar.random(io, .little); | 15 | const dhb = Secp256k1.scalar.random(io, .little); |
| ... | @@ -18,6 +21,8 @@ test "secp256k1 ECDH key exchange" { | ... | @@ -18,6 +21,8 @@ test "secp256k1 ECDH key exchange" { |
| 18 | } | 21 | } |
| 19 | | 22 | |
| 20 | test "secp256k1 ECDH key exchange including public multiplication" { | 23 | test "secp256k1 ECDH key exchange including public multiplication" { |
| | 24 | if (builtin.zig_backend == .stage2_llvm and builtin.target.cpu.arch.isPowerpc64()) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/37121 |
| | 25 | |
| 21 | const io = testing.io; | 26 | const io = testing.io; |
| 22 | const dha = Secp256k1.scalar.random(io, .little); | 27 | const dha = Secp256k1.scalar.random(io, .little); |
| 23 | const dhb = Secp256k1.scalar.random(io, .little); | 28 | const dhb = Secp256k1.scalar.random(io, .little); |
| ... | @@ -29,6 +34,8 @@ test "secp256k1 ECDH key exchange including public multiplication" { | ... | @@ -29,6 +34,8 @@ test "secp256k1 ECDH key exchange including public multiplication" { |
| 29 | } | 34 | } |
| 30 | | 35 | |
| 31 | test "secp256k1 point from affine coordinates" { | 36 | test "secp256k1 point from affine coordinates" { |
| | 37 | if (builtin.zig_backend == .stage2_llvm and builtin.target.cpu.arch.isPowerpc64()) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/37121 |
| | 38 | |
| 32 | const xh = "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"; | 39 | const xh = "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"; |
| 33 | const yh = "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"; | 40 | const yh = "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"; |
| 34 | var xs: [32]u8 = undefined; | 41 | var xs: [32]u8 = undefined; |
| ... | @@ -40,6 +47,8 @@ test "secp256k1 point from affine coordinates" { | ... | @@ -40,6 +47,8 @@ test "secp256k1 point from affine coordinates" { |
| 40 | } | 47 | } |
| 41 | | 48 | |
| 42 | test "secp256k1 test vectors" { | 49 | test "secp256k1 test vectors" { |
| | 50 | if (builtin.zig_backend == .stage2_llvm and builtin.target.cpu.arch.isPowerpc64()) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/37121 |
| | 51 | |
| 43 | const expected = [_][]const u8{ | 52 | const expected = [_][]const u8{ |
| 44 | "0000000000000000000000000000000000000000000000000000000000000000", | 53 | "0000000000000000000000000000000000000000000000000000000000000000", |
| 45 | "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", | 54 | "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", |
| ... | @@ -81,6 +90,8 @@ test "secp256k1 test vectors - doubling" { | ... | @@ -81,6 +90,8 @@ test "secp256k1 test vectors - doubling" { |
| 81 | } | 90 | } |
| 82 | | 91 | |
| 83 | test "secp256k1 compressed sec1 encoding/decoding" { | 92 | test "secp256k1 compressed sec1 encoding/decoding" { |
| | 93 | if (builtin.zig_backend == .stage2_llvm and builtin.target.cpu.arch.isPowerpc64()) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/37121 |
| | 94 | |
| 84 | const io = testing.io; | 95 | const io = testing.io; |
| 85 | const p = Secp256k1.random(io); | 96 | const p = Secp256k1.random(io); |
| 86 | const s = p.toCompressedSec1(); | 97 | const s = p.toCompressedSec1(); |
| ... | @@ -89,6 +100,8 @@ test "secp256k1 compressed sec1 encoding/decoding" { | ... | @@ -89,6 +100,8 @@ test "secp256k1 compressed sec1 encoding/decoding" { |
| 89 | } | 100 | } |
| 90 | | 101 | |
| 91 | test "secp256k1 uncompressed sec1 encoding/decoding" { | 102 | test "secp256k1 uncompressed sec1 encoding/decoding" { |
| | 103 | if (builtin.zig_backend == .stage2_llvm and builtin.target.cpu.arch.isPowerpc64()) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/37121 |
| | 104 | |
| 92 | const io = testing.io; | 105 | const io = testing.io; |
| 93 | const p = Secp256k1.random(io); | 106 | const p = Secp256k1.random(io); |
| 94 | const s = p.toUncompressedSec1(); | 107 | const s = p.toUncompressedSec1(); |
| ... | @@ -104,6 +117,8 @@ test "secp256k1 public key is the neutral element" { | ... | @@ -104,6 +117,8 @@ test "secp256k1 public key is the neutral element" { |
| 104 | } | 117 | } |
| 105 | | 118 | |
| 106 | test "secp256k1 public key is the neutral element (public verification)" { | 119 | test "secp256k1 public key is the neutral element (public verification)" { |
| | 120 | if (builtin.zig_backend == .stage2_llvm and builtin.target.cpu.arch.isPowerpc64()) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/37121 |
| | 121 | |
| 107 | const io = testing.io; | 122 | const io = testing.io; |
| 108 | const n = Secp256k1.scalar.Scalar.zero.toBytes(.little); | 123 | const n = Secp256k1.scalar.Scalar.zero.toBytes(.little); |
| 109 | const p = Secp256k1.random(io); | 124 | const p = Secp256k1.random(io); |
| ... | @@ -131,6 +146,8 @@ test "secp256k1 uncompressed SEC1 must not accept infinity" { | ... | @@ -131,6 +146,8 @@ test "secp256k1 uncompressed SEC1 must not accept infinity" { |
| 131 | } | 146 | } |
| 132 | | 147 | |
| 133 | test "secp256k1 double base multiplication" { | 148 | test "secp256k1 double base multiplication" { |
| | 149 | if (builtin.zig_backend == .stage2_llvm and builtin.target.cpu.arch.isPowerpc64()) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/37121 |
| | 150 | |
| 134 | const p1 = Secp256k1.basePoint; | 151 | const p1 = Secp256k1.basePoint; |
| 135 | const p2 = Secp256k1.basePoint.dbl(); | 152 | const p2 = Secp256k1.basePoint.dbl(); |
| 136 | const s1: [32]u8 = @splat(0x01); | 153 | const s1: [32]u8 = @splat(0x01); |
| ... | @@ -141,6 +158,8 @@ test "secp256k1 double base multiplication" { | ... | @@ -141,6 +158,8 @@ test "secp256k1 double base multiplication" { |
| 141 | } | 158 | } |
| 142 | | 159 | |
| 143 | test "secp256k1 public multiplication" { | 160 | test "secp256k1 public multiplication" { |
| | 161 | if (builtin.zig_backend == .stage2_llvm and builtin.target.cpu.arch.isPowerpc64()) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/37121 |
| | 162 | |
| 144 | const io = testing.io; | 163 | const io = testing.io; |
| 145 | const n = Secp256k1.scalar.field_order; | 164 | const n = Secp256k1.scalar.field_order; |
| 146 | const p = Secp256k1.random(io); | 165 | const p = Secp256k1.random(io); |