7
7
extern crate criterion;
8
8
9
9
use criterion:: Criterion ;
10
- use curve25519_dalek:: edwards:: EdwardsPoint ;
11
- use curve25519_dalek:: ristretto:: RistrettoPoint ;
10
+ use curve25519_dalek:: { edwards:: EdwardsPoint , ristretto:: RistrettoPoint } ;
12
11
use generic_array:: arr;
13
12
use opaque_ke:: {
14
13
group:: Group ,
15
- oprf:: { generate_oprf1_shim , generate_oprf2_shim , generate_oprf3_shim , OprfClientBytes } ,
14
+ oprf:: { blind_shim , evaluate_shim , unblind_and_finalize_shim } ,
16
15
} ;
17
16
use rand:: { prelude:: ThreadRng , thread_rng} ;
18
17
use sha2:: Sha256 ;
@@ -21,12 +20,9 @@ fn oprf1(c: &mut Criterion) {
21
20
let mut csprng: ThreadRng = thread_rng ( ) ;
22
21
let input = b"hunter2" ;
23
22
24
- c. bench_function ( "generate_oprf1 with Ristretto" , move |b| {
23
+ c. bench_function ( "blind with Ristretto" , move |b| {
25
24
b. iter ( || {
26
- let OprfClientBytes {
27
- alpha : _alpha,
28
- blinding_factor : _blinding_factor,
29
- } = generate_oprf1_shim :: < _ , RistrettoPoint > ( & input[ ..] , None , & mut csprng) . unwrap ( ) ;
25
+ blind_shim :: < _ , RistrettoPoint > ( & input[ ..] , & mut csprng) . unwrap ( ) ;
30
26
} )
31
27
} ) ;
32
28
}
@@ -35,12 +31,9 @@ fn oprf1_edwards(c: &mut Criterion) {
35
31
let mut csprng: ThreadRng = thread_rng ( ) ;
36
32
let input = b"hunter2" ;
37
33
38
- c. bench_function ( "generate_oprf1 with Edwards" , move |b| {
34
+ c. bench_function ( "blind with Edwards" , move |b| {
39
35
b. iter ( || {
40
- let OprfClientBytes {
41
- alpha : _alpha,
42
- blinding_factor : _blinding_factor,
43
- } = generate_oprf1_shim :: < _ , EdwardsPoint > ( & input[ ..] , None , & mut csprng) . unwrap ( ) ;
36
+ blind_shim :: < _ , EdwardsPoint > ( & input[ ..] , & mut csprng) . unwrap ( ) ;
44
37
} )
45
38
} ) ;
46
39
}
@@ -49,19 +42,16 @@ fn oprf2(c: &mut Criterion) {
49
42
let mut csprng: ThreadRng = thread_rng ( ) ;
50
43
let input = b"hunter2" ;
51
44
52
- let OprfClientBytes {
53
- alpha,
54
- blinding_factor : _blinding_factor,
55
- } = generate_oprf1_shim :: < _ , RistrettoPoint > ( & input[ ..] , None , & mut csprng) . unwrap ( ) ;
45
+ let ( _, alpha) = blind_shim :: < _ , RistrettoPoint > ( & input[ ..] , & mut csprng) . unwrap ( ) ;
56
46
let salt_bytes = arr ! [
57
47
u8 ; 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 ,
58
48
24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 ,
59
49
] ;
60
50
let salt = RistrettoPoint :: from_scalar_slice ( & salt_bytes) . unwrap ( ) ;
61
51
62
- c. bench_function ( "generate_oprf2 with Ristretto" , move |b| {
52
+ c. bench_function ( "evaluate with Ristretto" , move |b| {
63
53
b. iter ( || {
64
- let _beta = generate_oprf2_shim :: < RistrettoPoint > ( alpha, & salt) . unwrap ( ) ;
54
+ let _beta = evaluate_shim :: < RistrettoPoint > ( alpha, & salt) . unwrap ( ) ;
65
55
} )
66
56
} ) ;
67
57
}
@@ -70,19 +60,16 @@ fn oprf2_edwards(c: &mut Criterion) {
70
60
let mut csprng: ThreadRng = thread_rng ( ) ;
71
61
let input = b"hunter2" ;
72
62
73
- let OprfClientBytes {
74
- alpha,
75
- blinding_factor : _blinding_factor,
76
- } = generate_oprf1_shim :: < _ , EdwardsPoint > ( & input[ ..] , None , & mut csprng) . unwrap ( ) ;
63
+ let ( _, alpha) = blind_shim :: < _ , EdwardsPoint > ( & input[ ..] , & mut csprng) . unwrap ( ) ;
77
64
let salt_bytes = arr ! [
78
65
u8 ; 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 ,
79
66
24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 ,
80
67
] ;
81
68
let salt = RistrettoPoint :: from_scalar_slice ( & salt_bytes) . unwrap ( ) ;
82
69
83
- c. bench_function ( "generate_oprf2 with Edwards" , move |b| {
70
+ c. bench_function ( "evaluate with Edwards" , move |b| {
84
71
b. iter ( || {
85
- let _beta = generate_oprf2_shim :: < EdwardsPoint > ( alpha, & salt) . unwrap ( ) ;
72
+ let _beta = evaluate_shim :: < EdwardsPoint > ( alpha, & salt) . unwrap ( ) ;
86
73
} )
87
74
} ) ;
88
75
}
@@ -91,21 +78,17 @@ fn oprf3(c: &mut Criterion) {
91
78
let mut csprng: ThreadRng = thread_rng ( ) ;
92
79
let input = b"hunter2" ;
93
80
94
- let OprfClientBytes {
95
- alpha,
96
- blinding_factor,
97
- } = generate_oprf1_shim :: < _ , RistrettoPoint > ( & input[ ..] , None , & mut csprng) . unwrap ( ) ;
81
+ let ( token, alpha) = blind_shim :: < _ , RistrettoPoint > ( & input[ ..] , & mut csprng) . unwrap ( ) ;
98
82
let salt_bytes = arr ! [
99
83
u8 ; 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 ,
100
84
24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 ,
101
85
] ;
102
86
let salt = RistrettoPoint :: from_scalar_slice ( & salt_bytes) . unwrap ( ) ;
103
- let beta = generate_oprf2_shim :: < RistrettoPoint > ( alpha, & salt) . unwrap ( ) ;
87
+ let beta = evaluate_shim :: < RistrettoPoint > ( alpha, & salt) . unwrap ( ) ;
104
88
105
- c. bench_function ( "generate_oprf3 with Ristretto" , move |b| {
89
+ c. bench_function ( "unblind_and_finalize with Ristretto" , move |b| {
106
90
b. iter ( || {
107
- let _res = generate_oprf3_shim :: < RistrettoPoint , Sha256 > ( input, beta, & blinding_factor)
108
- . unwrap ( ) ;
91
+ let _res = unblind_and_finalize_shim :: < RistrettoPoint , Sha256 > ( & token, beta) . unwrap ( ) ;
109
92
} )
110
93
} ) ;
111
94
}
@@ -114,21 +97,17 @@ fn oprf3_edwards(c: &mut Criterion) {
114
97
let mut csprng: ThreadRng = thread_rng ( ) ;
115
98
let input = b"hunter2" ;
116
99
117
- let OprfClientBytes {
118
- alpha,
119
- blinding_factor,
120
- } = generate_oprf1_shim :: < _ , EdwardsPoint > ( & input[ ..] , None , & mut csprng) . unwrap ( ) ;
100
+ let ( token, alpha) = blind_shim :: < _ , EdwardsPoint > ( & input[ ..] , & mut csprng) . unwrap ( ) ;
121
101
let salt_bytes = arr ! [
122
102
u8 ; 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 ,
123
103
24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 ,
124
104
] ;
125
105
let salt = RistrettoPoint :: from_scalar_slice ( & salt_bytes) . unwrap ( ) ;
126
- let beta = generate_oprf2_shim :: < EdwardsPoint > ( alpha, & salt) . unwrap ( ) ;
106
+ let beta = evaluate_shim :: < EdwardsPoint > ( alpha, & salt) . unwrap ( ) ;
127
107
128
- c. bench_function ( "generate_oprf3 with Edwards" , move |b| {
108
+ c. bench_function ( "unblind_and_finalize with Edwards" , move |b| {
129
109
b. iter ( || {
130
- let _res =
131
- generate_oprf3_shim :: < EdwardsPoint , Sha256 > ( input, beta, & blinding_factor) . unwrap ( ) ;
110
+ let _res = unblind_and_finalize_shim :: < EdwardsPoint , Sha256 > ( & token, beta) . unwrap ( ) ;
132
111
} )
133
112
} ) ;
134
113
}
0 commit comments