bitcoin_key/
privkey.rs

1crate::ix!();
2
3//-------------------------------------------[.cpp/bitcoin/src/key.h]
4
5/**
6  | PrivKey is a serialized private key,
7  | with all parameters included (SIZE
8  | bytes)
9  |
10  */
11pub type PrivKey = Vec<u8,SecureAllocator>;
12
13/**
14  | secp256k1:
15  |
16  */
17pub const KEY_SIZE:            u32 = 279;
18pub const KEY_COMPRESSED_SIZE: u32 = 214;
19
20/**
21  | see www.keylength.com script supports
22  | up to 75 for single byte push
23  |
24  */
25const_assert!{
26    KEY_SIZE >= KEY_COMPRESSED_SIZE
27} //"COMPRESSED_SIZE is larger than SIZE"
28
29//-------------------------------------------[.cpp/bitcoin/src/key.cpp]
30
31lazy_static!{
32    /*
33    static secp256k1_context* secp256k1_context_sign = nullptr;
34    */
35}
36
37/*
38  | These functions are taken from the libsecp256k1
39  | distribution and are very ugly.
40  |
41  */
42
43
44/**
45  | Check that required EC support is available
46  | at runtime.
47  |
48  */
49pub fn ecc_init_sanity_check() -> bool {
50    
51    todo!();
52        /*
53            CKey key;
54        key.MakeNewKey(true);
55        CPubKey pubkey = key.GetPubKey();
56        return key.VerifyPubKey(pubkey);
57        */
58}
59
60/**
61  | Initialize the elliptic curve support.
62  | May not be called twice without calling
63  | ECC_Stop first.
64  |
65  */
66pub fn ecc_start()  {
67    
68    todo!();
69        /*
70            assert(secp256k1_context_sign == nullptr);
71
72        secp256k1_context *ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN);
73        assert(ctx != nullptr);
74
75        {
76            // Pass in a random blinding seed to the secp256k1 context.
77            std::vector<unsigned char, secure_allocator<unsigned char>> vseed(32);
78            GetRandBytes(vseed.data(), 32);
79            bool ret = secp256k1_context_randomize(ctx, vseed.data());
80            assert(ret);
81        }
82
83        secp256k1_context_sign = ctx;
84        */
85}
86
87/**
88  | Deinitialize the elliptic curve support.
89  | No-op if ECC_Start wasn't called first.
90  |
91  */
92pub fn ecc_stop()  {
93    
94    todo!();
95        /*
96            secp256k1_context *ctx = secp256k1_context_sign;
97        secp256k1_context_sign = nullptr;
98
99        if (ctx) {
100            secp256k1_context_destroy(ctx);
101        }
102        */
103}