| ... | ... | @@ -72,6 +72,8 @@ test "secp256k1 test vectors" { |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 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 | 77 | const expected = [_][]const u8{ |
| 76 | 78 | "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", |
| 77 | 79 | "c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5", |
| ... | ... | @@ -110,6 +112,8 @@ test "secp256k1 uncompressed sec1 encoding/decoding" { |
| 110 | 112 | } |
| 111 | 113 | |
| 112 | 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 | 117 | const io = testing.io; |
| 114 | 118 | const n = Secp256k1.scalar.Scalar.zero.toBytes(.little); |
| 115 | 119 | const p = Secp256k1.random(io); |
| ... | ... | @@ -126,17 +130,23 @@ test "secp256k1 public key is the neutral element (public verification)" { |
| 126 | 130 | } |
| 127 | 131 | |
| 128 | 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 | 135 | const s: [32]u8 = @splat(0xff); |
| 130 | 136 | try testing.expectError(error.NonCanonical, Secp256k1.Fe.fromBytes(s, .little)); |
| 131 | 137 | } |
| 132 | 138 | |
| 133 | 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 | 142 | try testing.expectError(error.InvalidEncoding, Secp256k1.fromAffineCoordinates(.{ .x = Secp256k1.Fe.zero, .y = Secp256k1.Fe.zero })); |
| 135 | 143 | try testing.expectError(error.InvalidEncoding, Secp256k1.fromAffineCoordinates(.{ .x = Secp256k1.Fe.zero, .y = Secp256k1.Fe.one })); |
| 136 | 144 | try testing.expectError(error.IdentityElement, Secp256k1.identityElement.rejectIdentity()); |
| 137 | 145 | } |
| 138 | 146 | |
| 139 | 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 | 150 | var buf: [65]u8 = @splat(0); |
| 141 | 151 | buf[0] = 0x04; |
| 142 | 152 | buf[64] = 0x01; |
| ... | ... | @@ -177,6 +187,8 @@ test "secp256k1 public multiplication" { |
| 177 | 187 | } |
| 178 | 188 | |
| 179 | 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 | 192 | const io = testing.io; |
| 181 | 193 | const n = Secp256k1.scalar.field_order; |
| 182 | 194 | inline for (.{ .little, .big }) |endian| { |
| ... | ... | @@ -193,6 +205,8 @@ test "secp256k1 scalar split" { |
| 193 | 205 | } |
| 194 | 206 | |
| 195 | 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 | 210 | const expected = "08d0684a0fe8ea978b68a29e4b4ffdbd19eeb59db25301cf23ecbe568e1f9822"; |
| 197 | 211 | var out: [32]u8 = undefined; |
| 198 | 212 | _ = try std.fmt.hexToBytes(&out, expected); |
| ... | ... | @@ -206,6 +220,8 @@ test "secp256k1 scalar inverse" { |
| 206 | 220 | } |
| 207 | 221 | |
| 208 | 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 | 225 | try std.testing.expect(Secp256k1.scalar.Scalar.zero.isOdd() == false); |
| 210 | 226 | try std.testing.expect(Secp256k1.scalar.Scalar.one.isOdd()); |
| 211 | 227 | try std.testing.expect(Secp256k1.scalar.Scalar.one.dbl().isOdd() == false); |