1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
use super::BigUintUncallable;
use crate::abi::TypeAbi;
use crate::api::EllipticCurveApi;
use crate::dharitri_codec::*;
use crate::types::BoxedBytes;
use alloc::string::String;

/// Dummy type that implements `EllipticCurveApi`.
/// Currently used to simplify generating ABIs, since we are not interested in values there.
/// Being completely content-less it can exist in `dharitri-wasm` in a no-std environment.

type EllipticCurveComponents<BigUint> = (BigUint, BigUint, BigUint, BigUint, BigUint, u32);
pub struct EllipticCurveUncallable;

impl TypeAbi for EllipticCurveUncallable {
    fn type_name() -> String {
        String::from("EllipticCurve")
    }
}

impl NestedEncode for EllipticCurveUncallable {
    fn dep_encode<O: NestedEncodeOutput>(&self, _dest: &mut O) -> Result<(), EncodeError> {
        unreachable!()
    }

    fn dep_encode_or_exit<O: NestedEncodeOutput, ExitCtx: Clone>(
        &self,
        _dest: &mut O,
        _c: ExitCtx,
        _exit: fn(ExitCtx, EncodeError) -> !,
    ) {
        unreachable!()
    }
}

impl TopEncode for EllipticCurveUncallable {
    fn top_encode<O: TopEncodeOutput>(&self, _output: O) -> Result<(), EncodeError> {
        unreachable!()
    }

    fn top_encode_or_exit<O: TopEncodeOutput, ExitCtx: Clone>(
        &self,
        _output: O,
        _c: ExitCtx,
        _exit: fn(ExitCtx, EncodeError) -> !,
    ) {
        unreachable!()
    }
}

impl EllipticCurveApi for EllipticCurveUncallable {
    type BigUint = BigUintUncallable;

    fn get_values(&self) -> EllipticCurveComponents<Self::BigUint> {
        unreachable!()
    }

    fn create_ec(_curve: &str) -> Self {
        unreachable!()
    }

    fn get_ec_length(&self) -> u32 {
        unreachable!()
    }

    fn get_priv_key_byte_length(&self) -> u32 {
        unreachable!()
    }

    fn add_ec(
        &self,
        _x_first_point: Self::BigUint,
        _y_first_point: Self::BigUint,
        _x_second_point: Self::BigUint,
        _y_second_point: Self::BigUint,
    ) -> (Self::BigUint, Self::BigUint) {
        unreachable!()
    }

    fn double_ec(
        &self,
        _x_point: Self::BigUint,
        _y_point: Self::BigUint,
    ) -> (Self::BigUint, Self::BigUint) {
        unreachable!()
    }

    fn is_on_curve_ec(&self, _x_point: Self::BigUint, _y_point: Self::BigUint) -> bool {
        unreachable!()
    }

    fn scalar_mult(
        &self,
        _x_point: Self::BigUint,
        _y_point: Self::BigUint,
        _data: BoxedBytes,
    ) -> (Self::BigUint, Self::BigUint) {
        unreachable!()
    }

    fn scalar_base_mult(&self, _data: BoxedBytes) -> (Self::BigUint, Self::BigUint) {
        unreachable!()
    }

    fn marshal_ec(&self, _x_pair: Self::BigUint, _y_pair: Self::BigUint) -> BoxedBytes {
        unreachable!()
    }

    fn marshal_compressed_ec(&self, _x_pair: Self::BigUint, _y_pair: Self::BigUint) -> BoxedBytes {
        unreachable!()
    }

    fn unmarshal_ec(&self, _data: BoxedBytes) -> (Self::BigUint, Self::BigUint) {
        unreachable!()
    }

    fn unmarshal_compressed_ec(&self, _data: BoxedBytes) -> (Self::BigUint, Self::BigUint) {
        unreachable!()
    }

    fn generate_key_ec(&self) -> (Self::BigUint, Self::BigUint, BoxedBytes) {
        unreachable!()
    }

    fn from_bitsize_ec(_bitsize: u32) -> Option<Self> {
        unreachable!()
    }
}