| ... | @@ -72,6 +72,8 @@ test "secp256k1 test vectors" { | ... | @@ -72,6 +72,8 @@ test "secp256k1 test vectors" { |
| 72 | } | 72 | } |
| 73 | | 73 | |
| 74 | test "secp256k1 test vectors - doubling" { | 74 | test "secp256k1 test vectors - doubling" { |
| | 75 | if (builtin.zig_backend == .stage2_llvm and builtin.target.cpu.arch.isPowerpc64()) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/37121 |
| | 76 | |
| 75 | const expected = [_][]const u8{ | 77 | const expected = [_][]const u8{ |
| 76 | "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", | 78 | "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", |
| 77 | "c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5", | 79 | "c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5", |
| ... | @@ -110,6 +112,8 @@ test "secp256k1 uncompressed sec1 encoding/decoding" { | ... | @@ -110,6 +112,8 @@ test "secp256k1 uncompressed sec1 encoding/decoding" { |
| 110 | } | 112 | } |
| 111 | | 113 | |
| 112 | test "secp256k1 public key is the neutral element" { | 114 | test "secp256k1 public key is the neutral element" { |
| | 115 | if (builtin.zig_backend == .stage2_llvm and builtin.target.cpu.arch.isPowerpc64()) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/37121 |
| | 116 | |
| 113 | const io = testing.io; | 117 | const io = testing.io; |
| 114 | const n = Secp256k1.scalar.Scalar.zero.toBytes(.little); | 118 | const n = Secp256k1.scalar.Scalar.zero.toBytes(.little); |
| 115 | const p = Secp256k1.random(io); | 119 | const p = Secp256k1.random(io); |
| ... | @@ -126,17 +130,23 @@ test "secp256k1 public key is the neutral element (public verification)" { | ... | @@ -126,17 +130,23 @@ test "secp256k1 public key is the neutral element (public verification)" { |
| 126 | } | 130 | } |
| 127 | | 131 | |
| 128 | test "secp256k1 field element non-canonical encoding" { | 132 | test "secp256k1 field element non-canonical encoding" { |
| | 133 | if (builtin.zig_backend == .stage2_llvm and builtin.target.cpu.arch.isPowerpc64()) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/37121 |
| | 134 | |
| 129 | const s: [32]u8 = @splat(0xff); | 135 | const s: [32]u8 = @splat(0xff); |
| 130 | try testing.expectError(error.NonCanonical, Secp256k1.Fe.fromBytes(s, .little)); | 136 | try testing.expectError(error.NonCanonical, Secp256k1.Fe.fromBytes(s, .little)); |
| 131 | } | 137 | } |
| 132 | | 138 | |
| 133 | test "secp256k1 neutral element decoding" { | 139 | test "secp256k1 neutral element decoding" { |
| | 140 | if (builtin.zig_backend == .stage2_llvm and builtin.target.cpu.arch.isPowerpc64()) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/37121 |
| | 141 | |
| 134 | try testing.expectError(error.InvalidEncoding, Secp256k1.fromAffineCoordinates(.{ .x = Secp256k1.Fe.zero, .y = Secp256k1.Fe.zero })); | 142 | try testing.expectError(error.InvalidEncoding, Secp256k1.fromAffineCoordinates(.{ .x = Secp256k1.Fe.zero, .y = Secp256k1.Fe.zero })); |
| 135 | try testing.expectError(error.InvalidEncoding, Secp256k1.fromAffineCoordinates(.{ .x = Secp256k1.Fe.zero, .y = Secp256k1.Fe.one })); | 143 | try testing.expectError(error.InvalidEncoding, Secp256k1.fromAffineCoordinates(.{ .x = Secp256k1.Fe.zero, .y = Secp256k1.Fe.one })); |
| 136 | try testing.expectError(error.IdentityElement, Secp256k1.identityElement.rejectIdentity()); | 144 | try testing.expectError(error.IdentityElement, Secp256k1.identityElement.rejectIdentity()); |
| 137 | } | 145 | } |
| 138 | | 146 | |
| 139 | test "secp256k1 uncompressed SEC1 must not accept infinity" { | 147 | test "secp256k1 uncompressed SEC1 must not accept infinity" { |
| | 148 | if (builtin.zig_backend == .stage2_llvm and builtin.target.cpu.arch.isPowerpc64()) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/37121 |
| | 149 | |
| 140 | var buf: [65]u8 = @splat(0); | 150 | var buf: [65]u8 = @splat(0); |
| 141 | buf[0] = 0x04; | 151 | buf[0] = 0x04; |
| 142 | buf[64] = 0x01; | 152 | buf[64] = 0x01; |
| ... | @@ -177,6 +187,8 @@ test "secp256k1 public multiplication" { | ... | @@ -177,6 +187,8 @@ test "secp256k1 public multiplication" { |
| 177 | } | 187 | } |
| 178 | | 188 | |
| 179 | test "secp256k1 scalar split" { | 189 | test "secp256k1 scalar split" { |
| | 190 | if (builtin.zig_backend == .stage2_llvm and builtin.target.cpu.arch.isPowerpc64()) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/37121 |
| | 191 | |
| 180 | const io = testing.io; | 192 | const io = testing.io; |
| 181 | const n = Secp256k1.scalar.field_order; | 193 | const n = Secp256k1.scalar.field_order; |
| 182 | inline for (.{ .little, .big }) |endian| { | 194 | inline for (.{ .little, .big }) |endian| { |
| ... | @@ -193,6 +205,8 @@ test "secp256k1 scalar split" { | ... | @@ -193,6 +205,8 @@ test "secp256k1 scalar split" { |
| 193 | } | 205 | } |
| 194 | | 206 | |
| 195 | test "secp256k1 scalar inverse" { | 207 | test "secp256k1 scalar inverse" { |
| | 208 | if (builtin.zig_backend == .stage2_llvm and builtin.target.cpu.arch.isPowerpc64()) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/37121 |
| | 209 | |
| 196 | const expected = "08d0684a0fe8ea978b68a29e4b4ffdbd19eeb59db25301cf23ecbe568e1f9822"; | 210 | const expected = "08d0684a0fe8ea978b68a29e4b4ffdbd19eeb59db25301cf23ecbe568e1f9822"; |
| 197 | var out: [32]u8 = undefined; | 211 | var out: [32]u8 = undefined; |
| 198 | _ = try std.fmt.hexToBytes(&out, expected); | 212 | _ = try std.fmt.hexToBytes(&out, expected); |
| ... | @@ -206,6 +220,8 @@ test "secp256k1 scalar inverse" { | ... | @@ -206,6 +220,8 @@ test "secp256k1 scalar inverse" { |
| 206 | } | 220 | } |
| 207 | | 221 | |
| 208 | test "secp256k1 scalar parity" { | 222 | test "secp256k1 scalar parity" { |
| | 223 | if (builtin.zig_backend == .stage2_llvm and builtin.target.cpu.arch.isPowerpc64()) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/37121 |
| | 224 | |
| 209 | try std.testing.expect(Secp256k1.scalar.Scalar.zero.isOdd() == false); | 225 | try std.testing.expect(Secp256k1.scalar.Scalar.zero.isOdd() == false); |
| 210 | try std.testing.expect(Secp256k1.scalar.Scalar.one.isOdd()); | 226 | try std.testing.expect(Secp256k1.scalar.Scalar.one.isOdd()); |
| 211 | try std.testing.expect(Secp256k1.scalar.Scalar.one.dbl().isOdd() == false); | 227 | try std.testing.expect(Secp256k1.scalar.Scalar.one.dbl().isOdd() == false); |