| ... | ... | @@ -1,3 +1,4 @@ |
| 1 | const builtin = @import("builtin"); |
| 1 | 2 | const std = @import("std"); |
| 2 | 3 | const fmt = std.fmt; |
| 3 | 4 | const testing = std.testing; |
| ... | ... | @@ -7,6 +8,8 @@ const Secp256k1 = @import("../secp256k1.zig").Secp256k1; |
| 7 | 8 | const lambda: u256 = 0x5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72; |
| 8 | 9 | |
| 9 | 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 | 13 | const io = testing.io; |
| 11 | 14 | const dha = Secp256k1.scalar.random(io, .little); |
| 12 | 15 | const dhb = Secp256k1.scalar.random(io, .little); |
| ... | ... | @@ -18,6 +21,8 @@ test "secp256k1 ECDH key exchange" { |
| 18 | 21 | } |
| 19 | 22 | |
| 20 | 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 | 26 | const io = testing.io; |
| 22 | 27 | const dha = Secp256k1.scalar.random(io, .little); |
| 23 | 28 | const dhb = Secp256k1.scalar.random(io, .little); |
| ... | ... | @@ -29,6 +34,8 @@ test "secp256k1 ECDH key exchange including public multiplication" { |
| 29 | 34 | } |
| 30 | 35 | |
| 31 | 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 | 39 | const xh = "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"; |
| 33 | 40 | const yh = "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"; |
| 34 | 41 | var xs: [32]u8 = undefined; |
| ... | ... | @@ -40,6 +47,8 @@ test "secp256k1 point from affine coordinates" { |
| 40 | 47 | } |
| 41 | 48 | |
| 42 | 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 | 52 | const expected = [_][]const u8{ |
| 44 | 53 | "0000000000000000000000000000000000000000000000000000000000000000", |
| 45 | 54 | "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", |
| ... | ... | @@ -81,6 +90,8 @@ test "secp256k1 test vectors - doubling" { |
| 81 | 90 | } |
| 82 | 91 | |
| 83 | 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 | 95 | const io = testing.io; |
| 85 | 96 | const p = Secp256k1.random(io); |
| 86 | 97 | const s = p.toCompressedSec1(); |
| ... | ... | @@ -89,6 +100,8 @@ test "secp256k1 compressed sec1 encoding/decoding" { |
| 89 | 100 | } |
| 90 | 101 | |
| 91 | 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 | 105 | const io = testing.io; |
| 93 | 106 | const p = Secp256k1.random(io); |
| 94 | 107 | const s = p.toUncompressedSec1(); |
| ... | ... | @@ -104,6 +117,8 @@ test "secp256k1 public key is the neutral element" { |
| 104 | 117 | } |
| 105 | 118 | |
| 106 | 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 | 122 | const io = testing.io; |
| 108 | 123 | const n = Secp256k1.scalar.Scalar.zero.toBytes(.little); |
| 109 | 124 | const p = Secp256k1.random(io); |
| ... | ... | @@ -131,6 +146,8 @@ test "secp256k1 uncompressed SEC1 must not accept infinity" { |
| 131 | 146 | } |
| 132 | 147 | |
| 133 | 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 | 151 | const p1 = Secp256k1.basePoint; |
| 135 | 152 | const p2 = Secp256k1.basePoint.dbl(); |
| 136 | 153 | const s1: [32]u8 = @splat(0x01); |
| ... | ... | @@ -141,6 +158,8 @@ test "secp256k1 double base multiplication" { |
| 141 | 158 | } |
| 142 | 159 | |
| 143 | 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 | 163 | const io = testing.io; |
| 145 | 164 | const n = Secp256k1.scalar.field_order; |
| 146 | 165 | const p = Secp256k1.random(io); |