mirror of
https://github.com/QuilibriumNetwork/ceremonyclient.git
synced 2026-02-21 18:37:26 +08:00
46 lines
733 B
Go
46 lines
733 B
Go
// -*- 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.qcl
|
|
// ./garbled -v -i 0x6d7472,0x321af130,0xd60b2b09,0x10001 examples/rsa.qcl
|
|
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
|
|
}
|