-
Notifications
You must be signed in to change notification settings - Fork 34
/
elliptic_curves.hpp
88 lines (76 loc) · 3.08 KB
/
elliptic_curves.hpp
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
/**
* Copyright Quadrivium LLC
* All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "common/blob.hpp"
#include "common/buffer.hpp"
#include "common/buffer_view.hpp"
namespace kagome::crypto {
class EllipticCurves {
public:
virtual ~EllipticCurves() = default;
/**
* Pairing multi Miller loop for BLS12-381.
* @param a
* ArkScale<Vec<ark_ec::bls12::G1Prepared::<ark_bls12_381::Config>>>
* @param b
* ArkScale<Vec<ark_ec::bls12::G1Prepared::<ark_bls12_381::Config>>>
* @return ArkScale<MillerLoopOutput<Bls12<ark_bls12_381::Config>>>
*/
virtual outcome::result<common::Buffer> bls12_381_multi_miller_loop(
common::BufferView a, common::BufferView b) const = 0;
/**
* Pairing final exponentiation for BLS12-381.
* @param f ArkScale<MillerLoopOutput<Bls12<ark_bls12_381::Config>>>
* @return ArkScale<PairingOutput<Bls12<ark_bls12_381::Config>>>
*/
virtual outcome::result<common::Buffer> bls12_381_final_exponentiation(
common::BufferView f) const = 0;
/**
* Projective multiplication on G1 for BLS12-381.
* @param base ArkScaleProjective<ark_bls12_381::G1Projective>
* @param scalar ArkScale<&[u64]>
* @return ArkScaleProjective<ark_bls12_381::G1Projective>
*/
virtual outcome::result<common::Buffer> bls12_381_mul_projective_g1(
common::BufferView base, common::BufferView scalar) const = 0;
/**
* Projective multiplication on G2 for BLS12-381.
* @param base ArkScaleProjective<ark_bls12_381::G2Projective>
* @param scalar ArkScale<&[u64]>
* @return ArkScaleProjective<ark_bls12_381::G2Projective>
*/
virtual outcome::result<common::Buffer> bls12_381_mul_projective_g2(
common::BufferView base, common::BufferView scalar) const = 0;
/**
* Multi scalar multiplication on G1 for BLS12-381.
* @param bases ArkScale<&[ark_bls12_381::G1Affine]>
* @param scalars ArkScale<&[ark_bls12_381::Fr]>
* @return ArkScaleProjective<ark_bls12_381::G1Projective>
*/
virtual outcome::result<common::Buffer> bls12_381_msm_g1(
common::BufferView bases, common::BufferView scalars) const = 0;
/**
* Multi scalar multiplication on G2 for BLS12-381.
* @param bases ArkScale<&[ark_bls12_381::G2Affine]>
* @param scalars ArkScale<&[ark_bls12_381::Fr]>
* @return ArkScaleProjective<ark_bls12_381::G2Projective>
*/
virtual outcome::result<common::Buffer> bls12_381_msm_g2(
common::BufferView bases, common::BufferView scalars) const = 0;
/**
* Short Weierstrass projective multiplication for
* Ed-on-BLS12-381-Bandersnatch.
* @param base
* ArkScaleProjective<ark_ed_on_bls12_381_bandersnatch::SWProjective>
* @param scalar ArkScale<&[u64]>
* @return
* ArkScaleProjective<ark_ed_on_bls12_381_bandersnatch::SWProjective>
*/
virtual outcome::result<common::Buffer>
ed_on_bls12_381_bandersnatch_sw_mul_projective(
common::BufferView base, common::BufferView scalar) const = 0;
};
} // namespace kagome::crypto