1
1
// TODO: think about safe integers and overflow
2
2
3
+ 'use strict' ;
4
+
3
5
var twoto32 = MAX_VALUE ;
4
6
5
7
describe ( "Unsigned integer conversion" , function ( ) {
@@ -82,7 +84,7 @@ describe("MPC for single values", function () {
82
84
expect ( given ) . toEqual ( expected ) ;
83
85
} ) ;
84
86
85
- it ( "should throw when input >= 2^32" , function ( ) {
87
+ it ( "should throw when input to secret sharing >= 2^32" , function ( ) {
86
88
var f = function ( ) {
87
89
_secretShare ( twoto32 , 2 ) ;
88
90
} ;
@@ -93,7 +95,7 @@ describe("MPC for single values", function () {
93
95
expect ( f ) . toThrow ( new Error ( 'Input value outside valid range' ) ) ;
94
96
} ) ;
95
97
96
- it ( "should throw when input is negative" , function ( ) {
98
+ it ( "should throw when input to secret sharing is negative" , function ( ) {
97
99
var f = function ( ) {
98
100
_secretShare ( - 1 , 2 ) ;
99
101
} ;
@@ -225,6 +227,13 @@ describe("MPC for objects", function () {
225
227
expect ( result ) . toEqual ( expected ) ;
226
228
} ) ;
227
229
230
+ it ( "should correctly count out-of-bounds in analyst shares" , function ( ) {
231
+ var shares = [ { k : '-1' } , { k : '4294967296' } , { k : '4294967297' } , { k : '7' } ] ,
232
+ result = countInvalidShares ( shares ) ,
233
+ expected = { k : 3 } ;
234
+ expect ( result ) . toEqual ( expected ) ;
235
+ } ) ;
236
+
228
237
it ( "should correctly count out-of-bounds in service shares" , function ( ) {
229
238
var shares = [ { k : - 1 } , { k : - 10 } , { k : 10 } , { k : twoto32 } , { k : twoto32 + 1 } ] ,
230
239
wrappedShares = shares . map ( function ( share ) { return { fields : share } } ) ,
0 commit comments