-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathrsa.mpcl
More file actions
45 lines (37 loc) · 735 Bytes
/
Copy pathrsa.mpcl
File metadata and controls
45 lines (37 loc) · 735 Bytes
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
// -*- go -*-
//
// 32-bit RSA encryption and decryption.
//
// The key parameters are:
//
// d: 0x321af139
// n: 0xd60b2b09
// e: 0x10001
//
// private: d, n
// public: e, n
//
// msg: 0x6d7472
// cipher: 0x61f9ef88
//
// Run garbler and evaluator as follows:
//
// ./garbled -e -v -i 9 examples/rsa.mpcl
// ./garbled -v -i 0x6d7472,0x321af130,0xd60b2b09,0x10001 examples/rsa.mpcl
package main
import (
"crypto/rsa"
)
type Size = uint32
type Garbler struct {
msg Size
privShare Size
pubN Size
pubE Size
}
func main(g Garbler, privShare Size) (uint, uint) {
priv := g.privShare + privShare
cipher := rsa.Encrypt(g.msg, g.pubE, g.pubN)
plain := rsa.Decrypt(cipher, priv, g.pubN)
return cipher, plain
}