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