@qntx/nostr-native 0.0.0-stage → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-APACHE +201 -0
- package/LICENSE-MIT +21 -0
- package/NostrNative.podspec +37 -0
- package/README.md +30 -2
- package/android/CMakeLists.txt +38 -0
- package/android/build.gradle +136 -0
- package/android/gradle.properties +4 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +7 -0
- package/android/src/main/java/com/margelo/nitro/nostrnative/NostrNativePackage.java +29 -0
- package/cpp/HybridNostrNative.cpp +52 -0
- package/cpp/HybridNostrNative.hpp +22 -0
- package/cpp/nostr_core.c +128 -0
- package/cpp/nostr_core.h +65 -0
- package/cpp/nostr_native.c +54 -0
- package/cpp/nostr_native.h +47 -0
- package/dist/index.d.mts +15 -0
- package/dist/index.mjs +26 -0
- package/dist/index.mjs.map +1 -0
- package/nitro.json +19 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NostrNative+autolinking.cmake +81 -0
- package/nitrogen/generated/android/NostrNative+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NostrNativeOnLoad.cpp +49 -0
- package/nitrogen/generated/android/NostrNativeOnLoad.hpp +34 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nostrnative/NostrNativeOnLoad.kt +35 -0
- package/nitrogen/generated/ios/NostrNative+autolinking.rb +62 -0
- package/nitrogen/generated/ios/NostrNative-Swift-Cxx-Bridge.cpp +17 -0
- package/nitrogen/generated/ios/NostrNative-Swift-Cxx-Bridge.hpp +27 -0
- package/nitrogen/generated/ios/NostrNative-Swift-Cxx-Umbrella.hpp +38 -0
- package/nitrogen/generated/ios/NostrNativeAutolinking.mm +35 -0
- package/nitrogen/generated/ios/NostrNativeAutolinking.swift +16 -0
- package/nitrogen/generated/shared/c++/HybridNostrNativeSpec.cpp +23 -0
- package/nitrogen/generated/shared/c++/HybridNostrNativeSpec.hpp +64 -0
- package/package.json +86 -4
- package/react-native.config.js +12 -0
- package/vendor/secp256k1/COPYING +19 -0
- package/vendor/secp256k1/include/secp256k1.h +931 -0
- package/vendor/secp256k1/include/secp256k1_ecdh.h +63 -0
- package/vendor/secp256k1/include/secp256k1_ellswift.h +200 -0
- package/vendor/secp256k1/include/secp256k1_extrakeys.h +250 -0
- package/vendor/secp256k1/include/secp256k1_musig.h +588 -0
- package/vendor/secp256k1/include/secp256k1_preallocated.h +134 -0
- package/vendor/secp256k1/include/secp256k1_recovery.h +123 -0
- package/vendor/secp256k1/include/secp256k1_schnorrsig.h +179 -0
- package/vendor/secp256k1/include/secp256k1_silentpayments.h +396 -0
- package/vendor/secp256k1/src/assumptions.h +87 -0
- package/vendor/secp256k1/src/checkmem.h +117 -0
- package/vendor/secp256k1/src/ecdsa.h +21 -0
- package/vendor/secp256k1/src/ecdsa_impl.h +309 -0
- package/vendor/secp256k1/src/eckey.h +28 -0
- package/vendor/secp256k1/src/eckey_impl.h +94 -0
- package/vendor/secp256k1/src/ecmult.h +64 -0
- package/vendor/secp256k1/src/ecmult_compute_table.h +16 -0
- package/vendor/secp256k1/src/ecmult_compute_table_impl.h +49 -0
- package/vendor/secp256k1/src/ecmult_const.h +38 -0
- package/vendor/secp256k1/src/ecmult_const_impl.h +402 -0
- package/vendor/secp256k1/src/ecmult_gen.h +145 -0
- package/vendor/secp256k1/src/ecmult_gen_compute_table.h +14 -0
- package/vendor/secp256k1/src/ecmult_gen_compute_table_impl.h +108 -0
- package/vendor/secp256k1/src/ecmult_gen_impl.h +347 -0
- package/vendor/secp256k1/src/ecmult_impl.h +869 -0
- package/vendor/secp256k1/src/field.h +351 -0
- package/vendor/secp256k1/src/field_10x26.h +57 -0
- package/vendor/secp256k1/src/field_10x26_impl.h +1210 -0
- package/vendor/secp256k1/src/field_5x52.h +62 -0
- package/vendor/secp256k1/src/field_5x52_impl.h +496 -0
- package/vendor/secp256k1/src/field_5x52_int128_impl.h +274 -0
- package/vendor/secp256k1/src/field_impl.h +457 -0
- package/vendor/secp256k1/src/group.h +218 -0
- package/vendor/secp256k1/src/group_impl.h +1014 -0
- package/vendor/secp256k1/src/hash.h +56 -0
- package/vendor/secp256k1/src/hash_impl.h +397 -0
- package/vendor/secp256k1/src/hsort.h +33 -0
- package/vendor/secp256k1/src/hsort_impl.h +125 -0
- package/vendor/secp256k1/src/int128.h +90 -0
- package/vendor/secp256k1/src/int128_impl.h +18 -0
- package/vendor/secp256k1/src/int128_native.h +19 -0
- package/vendor/secp256k1/src/int128_native_impl.h +94 -0
- package/vendor/secp256k1/src/int128_struct.h +14 -0
- package/vendor/secp256k1/src/int128_struct_impl.h +205 -0
- package/vendor/secp256k1/src/modinv32.h +43 -0
- package/vendor/secp256k1/src/modinv32_impl.h +725 -0
- package/vendor/secp256k1/src/modinv64.h +47 -0
- package/vendor/secp256k1/src/modinv64_impl.h +780 -0
- package/vendor/secp256k1/src/modules/extrakeys/main_impl.h +292 -0
- package/vendor/secp256k1/src/modules/schnorrsig/main_impl.h +256 -0
- package/vendor/secp256k1/src/precomputed_ecmult.c +16456 -0
- package/vendor/secp256k1/src/precomputed_ecmult.h +40 -0
- package/vendor/secp256k1/src/precomputed_ecmult_gen.c +1779 -0
- package/vendor/secp256k1/src/precomputed_ecmult_gen.h +28 -0
- package/vendor/secp256k1/src/scalar.h +105 -0
- package/vendor/secp256k1/src/scalar_4x64.h +19 -0
- package/vendor/secp256k1/src/scalar_4x64_impl.h +1005 -0
- package/vendor/secp256k1/src/scalar_8x32.h +19 -0
- package/vendor/secp256k1/src/scalar_8x32_impl.h +820 -0
- package/vendor/secp256k1/src/scalar_impl.h +321 -0
- package/vendor/secp256k1/src/scalar_low.h +24 -0
- package/vendor/secp256k1/src/scalar_low_impl.h +217 -0
- package/vendor/secp256k1/src/scratch.h +44 -0
- package/vendor/secp256k1/src/scratch_impl.h +99 -0
- package/vendor/secp256k1/src/secp256k1.c +855 -0
- package/vendor/secp256k1/src/selftest.h +41 -0
- package/vendor/secp256k1/src/util.h +479 -0
- package/vendor/secp256k1/src/util_local_visibility.h +12 -0
- package/vendor/secp256k1/vendored.json +6 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*********************************************************************************
|
|
2
|
+
* Copyright (c) 2013, 2014, 2015, 2021 Thomas Daede, Cory Fields, Pieter Wuille *
|
|
3
|
+
* Distributed under the MIT software license, see the accompanying *
|
|
4
|
+
* file COPYING or https://www.opensource.org/licenses/mit-license.php. *
|
|
5
|
+
*********************************************************************************/
|
|
6
|
+
|
|
7
|
+
#ifndef SECP256K1_PRECOMPUTED_ECMULT_GEN_H
|
|
8
|
+
#define SECP256K1_PRECOMPUTED_ECMULT_GEN_H
|
|
9
|
+
|
|
10
|
+
#ifdef __cplusplus
|
|
11
|
+
extern "C" {
|
|
12
|
+
#endif
|
|
13
|
+
|
|
14
|
+
#include "group.h"
|
|
15
|
+
#include "ecmult_gen.h"
|
|
16
|
+
#include "util_local_visibility.h"
|
|
17
|
+
|
|
18
|
+
#ifdef EXHAUSTIVE_TEST_ORDER
|
|
19
|
+
static nostr_native_secp256k1_ge_storage nostr_native_secp256k1_ecmult_gen_prec_table[COMB_BLOCKS][COMB_POINTS];
|
|
20
|
+
#else
|
|
21
|
+
SECP256K1_LOCAL_VAR const nostr_native_secp256k1_ge_storage nostr_native_secp256k1_ecmult_gen_prec_table[COMB_BLOCKS][COMB_POINTS];
|
|
22
|
+
#endif /* defined(EXHAUSTIVE_TEST_ORDER) */
|
|
23
|
+
|
|
24
|
+
#ifdef __cplusplus
|
|
25
|
+
}
|
|
26
|
+
#endif
|
|
27
|
+
|
|
28
|
+
#endif /* SECP256K1_PRECOMPUTED_ECMULT_GEN_H */
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/***********************************************************************
|
|
2
|
+
* Copyright (c) 2014 Pieter Wuille *
|
|
3
|
+
* Distributed under the MIT software license, see the accompanying *
|
|
4
|
+
* file COPYING or https://www.opensource.org/licenses/mit-license.php.*
|
|
5
|
+
***********************************************************************/
|
|
6
|
+
|
|
7
|
+
#ifndef SECP256K1_SCALAR_H
|
|
8
|
+
#define SECP256K1_SCALAR_H
|
|
9
|
+
|
|
10
|
+
#include "util.h"
|
|
11
|
+
|
|
12
|
+
#if defined(EXHAUSTIVE_TEST_ORDER)
|
|
13
|
+
#include "scalar_low.h"
|
|
14
|
+
#elif defined(SECP256K1_WIDEMUL_INT128)
|
|
15
|
+
#include "scalar_4x64.h"
|
|
16
|
+
#elif defined(SECP256K1_WIDEMUL_INT64)
|
|
17
|
+
#include "scalar_8x32.h"
|
|
18
|
+
#else
|
|
19
|
+
#error "Please select wide multiplication implementation"
|
|
20
|
+
#endif
|
|
21
|
+
|
|
22
|
+
/** Clear a scalar to prevent the leak of sensitive data. */
|
|
23
|
+
static void nostr_native_secp256k1_scalar_clear(nostr_native_secp256k1_scalar *r);
|
|
24
|
+
|
|
25
|
+
/** Access bits (1 <= count <= 32) from a scalar. All requested bits must belong to the same 32-bit limb. */
|
|
26
|
+
static uint32_t nostr_native_secp256k1_scalar_get_bits_limb32(const nostr_native_secp256k1_scalar *a, unsigned int offset, unsigned int count);
|
|
27
|
+
|
|
28
|
+
/** Access bits (1 <= count <= 32) from a scalar. offset + count must be <= 256. Not constant time in offset and count. */
|
|
29
|
+
static uint32_t nostr_native_secp256k1_scalar_get_bits_var(const nostr_native_secp256k1_scalar *a, unsigned int offset, unsigned int count);
|
|
30
|
+
|
|
31
|
+
/** Set a scalar from a big endian byte array. The scalar will be reduced modulo group order `n`.
|
|
32
|
+
* In: bin: pointer to a 32-byte array.
|
|
33
|
+
* Out: r: scalar to be set.
|
|
34
|
+
* overflow: non-zero if the scalar was bigger or equal to `n` before reduction, zero otherwise (can be NULL).
|
|
35
|
+
*/
|
|
36
|
+
static void nostr_native_secp256k1_scalar_set_b32(nostr_native_secp256k1_scalar *r, const unsigned char *bin, int *overflow);
|
|
37
|
+
|
|
38
|
+
/** Set a scalar from a big endian byte array and returns 1 if it is a valid
|
|
39
|
+
* seckey and 0 otherwise. */
|
|
40
|
+
static int nostr_native_secp256k1_scalar_set_b32_seckey(nostr_native_secp256k1_scalar *r, const unsigned char *bin);
|
|
41
|
+
|
|
42
|
+
/** Set a scalar to an unsigned integer. */
|
|
43
|
+
static void nostr_native_secp256k1_scalar_set_int(nostr_native_secp256k1_scalar *r, unsigned int v);
|
|
44
|
+
|
|
45
|
+
/** Convert a scalar to a byte array. */
|
|
46
|
+
static void nostr_native_secp256k1_scalar_get_b32(unsigned char *bin, const nostr_native_secp256k1_scalar* a);
|
|
47
|
+
|
|
48
|
+
/** Add two scalars together (modulo the group order). Returns whether it overflowed. */
|
|
49
|
+
static int nostr_native_secp256k1_scalar_add(nostr_native_secp256k1_scalar *r, const nostr_native_secp256k1_scalar *a, const nostr_native_secp256k1_scalar *b);
|
|
50
|
+
|
|
51
|
+
/** Conditionally add a power of two to a scalar. The result is not allowed to overflow. Flag must be 0 or 1. */
|
|
52
|
+
static void nostr_native_secp256k1_scalar_cadd_bit(nostr_native_secp256k1_scalar *r, unsigned int bit, int flag);
|
|
53
|
+
|
|
54
|
+
/** Multiply two scalars (modulo the group order). */
|
|
55
|
+
static void nostr_native_secp256k1_scalar_mul(nostr_native_secp256k1_scalar *r, const nostr_native_secp256k1_scalar *a, const nostr_native_secp256k1_scalar *b);
|
|
56
|
+
|
|
57
|
+
/** Compute the inverse of a scalar (modulo the group order). */
|
|
58
|
+
static void nostr_native_secp256k1_scalar_inverse(nostr_native_secp256k1_scalar *r, const nostr_native_secp256k1_scalar *a);
|
|
59
|
+
|
|
60
|
+
/** Compute the inverse of a scalar (modulo the group order), without constant-time guarantee. */
|
|
61
|
+
static void nostr_native_secp256k1_scalar_inverse_var(nostr_native_secp256k1_scalar *r, const nostr_native_secp256k1_scalar *a);
|
|
62
|
+
|
|
63
|
+
/** Compute the complement of a scalar (modulo the group order). */
|
|
64
|
+
static void nostr_native_secp256k1_scalar_negate(nostr_native_secp256k1_scalar *r, const nostr_native_secp256k1_scalar *a);
|
|
65
|
+
|
|
66
|
+
/** Multiply a scalar with the multiplicative inverse of 2. */
|
|
67
|
+
static void nostr_native_secp256k1_scalar_half(nostr_native_secp256k1_scalar *r, const nostr_native_secp256k1_scalar *a);
|
|
68
|
+
|
|
69
|
+
/** Check whether a scalar equals zero. */
|
|
70
|
+
static int nostr_native_secp256k1_scalar_is_zero(const nostr_native_secp256k1_scalar *a);
|
|
71
|
+
|
|
72
|
+
/** Check whether a scalar equals one. */
|
|
73
|
+
static int nostr_native_secp256k1_scalar_is_one(const nostr_native_secp256k1_scalar *a);
|
|
74
|
+
|
|
75
|
+
/** Check whether a scalar, considered as an nonnegative integer, is even. */
|
|
76
|
+
static int nostr_native_secp256k1_scalar_is_even(const nostr_native_secp256k1_scalar *a);
|
|
77
|
+
|
|
78
|
+
/** Check whether a scalar is higher than the group order divided by 2. */
|
|
79
|
+
static int nostr_native_secp256k1_scalar_is_high(const nostr_native_secp256k1_scalar *a);
|
|
80
|
+
|
|
81
|
+
/** Conditionally negate a number, in constant time. Flag must be 0 or 1.
|
|
82
|
+
* Returns -1 if the number was negated, 1 otherwise */
|
|
83
|
+
static int nostr_native_secp256k1_scalar_cond_negate(nostr_native_secp256k1_scalar *a, int flag);
|
|
84
|
+
|
|
85
|
+
/** Compare two scalars. */
|
|
86
|
+
static int nostr_native_secp256k1_scalar_eq(const nostr_native_secp256k1_scalar *a, const nostr_native_secp256k1_scalar *b);
|
|
87
|
+
|
|
88
|
+
/** Find r1 and r2 such that r1+r2*2^128 = k. */
|
|
89
|
+
static void nostr_native_secp256k1_scalar_split_128(nostr_native_secp256k1_scalar *r1, nostr_native_secp256k1_scalar *r2, const nostr_native_secp256k1_scalar *k);
|
|
90
|
+
/** Find r1 and r2 such that r1+r2*lambda = k, where r1 and r2 or their
|
|
91
|
+
* negations are maximum 128 bits long (see nostr_native_secp256k1_ge_mul_lambda). It is
|
|
92
|
+
* required that r1, r2, and k all point to different objects. */
|
|
93
|
+
static void nostr_native_secp256k1_scalar_split_lambda(nostr_native_secp256k1_scalar * SECP256K1_RESTRICT r1, nostr_native_secp256k1_scalar * SECP256K1_RESTRICT r2, const nostr_native_secp256k1_scalar * SECP256K1_RESTRICT k);
|
|
94
|
+
|
|
95
|
+
/** Multiply a and b (without taking the modulus!), divide by 2**shift, and round to the nearest integer. Shift must be at least 256. */
|
|
96
|
+
static void nostr_native_secp256k1_scalar_mul_shift_var(nostr_native_secp256k1_scalar *r, const nostr_native_secp256k1_scalar *a, const nostr_native_secp256k1_scalar *b, unsigned int shift);
|
|
97
|
+
|
|
98
|
+
/** If flag is 1, set *r equal to *a; if flag is 0, leave it. Constant-time. Both *r and *a must be initialized. Flag must be 0 or 1. */
|
|
99
|
+
static void nostr_native_secp256k1_scalar_cmov(nostr_native_secp256k1_scalar *r, const nostr_native_secp256k1_scalar *a, int flag);
|
|
100
|
+
|
|
101
|
+
/** Check invariants on a scalar (no-op unless VERIFY is enabled). */
|
|
102
|
+
static void nostr_native_secp256k1_scalar_verify(const nostr_native_secp256k1_scalar *r);
|
|
103
|
+
#define SECP256K1_SCALAR_VERIFY(r) nostr_native_secp256k1_scalar_verify(r)
|
|
104
|
+
|
|
105
|
+
#endif /* SECP256K1_SCALAR_H */
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/***********************************************************************
|
|
2
|
+
* Copyright (c) 2014 Pieter Wuille *
|
|
3
|
+
* Distributed under the MIT software license, see the accompanying *
|
|
4
|
+
* file COPYING or https://www.opensource.org/licenses/mit-license.php.*
|
|
5
|
+
***********************************************************************/
|
|
6
|
+
|
|
7
|
+
#ifndef SECP256K1_SCALAR_REPR_H
|
|
8
|
+
#define SECP256K1_SCALAR_REPR_H
|
|
9
|
+
|
|
10
|
+
#include <stdint.h>
|
|
11
|
+
|
|
12
|
+
/** A scalar modulo the group order of the secp256k1 curve. */
|
|
13
|
+
typedef struct {
|
|
14
|
+
uint64_t d[4];
|
|
15
|
+
} nostr_native_secp256k1_scalar;
|
|
16
|
+
|
|
17
|
+
#define SECP256K1_SCALAR_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{((uint64_t)(d1)) << 32 | (d0), ((uint64_t)(d3)) << 32 | (d2), ((uint64_t)(d5)) << 32 | (d4), ((uint64_t)(d7)) << 32 | (d6)}}
|
|
18
|
+
|
|
19
|
+
#endif /* SECP256K1_SCALAR_REPR_H */
|