func CreateRSW2048A2PuzzleECIES(t uint64, message []byte) (ciphertext []byte, puzzle crypto.Puzzle, err error) {
	// Generate ecdsa s256
	var ecdsaPrivKey *ecdsa.PrivateKey
	if ecdsaPrivKey, err = ethcrypto.GenerateKey(); err != nil {
		err = fmt.Errorf("Error generating ecdsa key for ecies puzzle: %s", err)
		return
	}

	// turn into bytes
	var eciesPrivKeyBytes []byte
	eciesPrivKeyBytes = ethcrypto.FromECDSA(ecdsaPrivKey)

	// Set up what the puzzle will encrypt (the ecies key, which we marshal using ASN.1 ECPKS)
	var timelock crypto.Timelock
	if timelock, err = rsw.New2048A2(eciesPrivKeyBytes); err != nil {
		err = fmt.Errorf("Error creating new rsw timelock for ecies puzzle: %s", err)
		return
	}

	// Set up the puzzle to send
	if puzzle, _, err = timelock.SetupTimelockPuzzle(t); err != nil {
		err = fmt.Errorf("Error setting up timelock while creating rsa puzzle: %s", err)
		return
	}

	// Actually get the ecies privkey that we sign with using the bytes from before.
	var eciesPrivKey *ecies.PrivateKey
	eciesPrivKey = ecies.ImportECDSA(ecdsaPrivKey)

	// Encrypt the message into the ciphertext so we can then send it out along with the puzzle
	// sharedInfo1 and sharedInfo2 (s1, s2) are not going to be needed (they are nil) because we assume no shared data
	// between the solver and creator of the puzzle.
	if ciphertext, err = ecies.Encrypt(rand.Reader, &eciesPrivKey.PublicKey, message, nil, nil); err != nil {
		err = fmt.Errorf("Error creating ciphertext for ecies puzzle: %s", err)
		return
	}
	// We've now sent out the puzzle (which is n, a, t, ck)

	return
}
// CreateRSW2048A2PuzzleECIES creates a RSW timelock puzzle with time t and encrypts the message using ECIES.
// We're using seckp256k1.
// Here's our process because working with ethereum types is annoying and people seem to not like marshalling private keys
// Generate s256 ethcrypto ecdsa key -> use FromECDSA to create bytes with ethcrypto lib, convert to ecies privkey and encrypt message -> send that in puzzle -> once puzzle is solved, unmarshal to ecies privkey, use to decrypt
CreateRSW2048A2PuzzleECIES creates a RSW timelock puzzle with time t and encrypts the message using ECIES.
We're using seckp256k1.
Here's our process because working with ethereum types is annoying and people seem to not like marshalling private keys
Generate s256 ethcrypto ecdsa key -> use FromECDSA to create bytes with ethcrypto lib, convert to ecies privkey and encrypt message -> send that in puzzle -> once puzzle is solved, unmarshal to ecies privkey, use to decrypt
// CreateRSW2048A2PuzzleECIES creates a RSW timelock puzzle with time t and encrypts the message using ECIES . // We ' re using seckp256k1 . // Here ' s our process because working with ethereum types is annoying and people seem to not like marshalling private keys // Generate s256 ethcrypto ecdsa key - > use FromECDSA to create bytes with ethcrypto lib convert to ecies privkey and encrypt message - > send that in puzzle - > once puzzle is solved unmarshal to ecies privkey use to decrypt
func CreateRSW2048A2PuzzleECIES(t uint64, message []byte) (ciphertext []byte, puzzle crypto.Puzzle, err error) {
	var ecdsaPrivKey *ecdsa.PrivateKey
	if ecdsaPrivKey, err = ethcrypto.GenerateKey(); err != nil {
		err = fmt.Errorf("Error generating ecdsa key for ecies puzzle: %s", err)
		return
	}
	var eciesPrivKeyBytes []byte
	eciesPrivKeyBytes = ethcrypto.FromECDSA(ecdsaPrivKey)
	var timelock crypto.Timelock
	if timelock, err = rsw.New2048A2(eciesPrivKeyBytes); err != nil {
		err = fmt.Errorf("Error creating new rsw timelock for ecies puzzle: %s", err)
		return
	}
	if puzzle, _, err = timelock.SetupTimelockPuzzle(t); err != nil {
		err = fmt.Errorf("Error setting up timelock while creating rsa puzzle: %s", err)
		return
	}
	var eciesPrivKey *ecies.PrivateKey
	eciesPrivKey = ecies.ImportECDSA(ecdsaPrivKey)
	if ciphertext, err = ecies.Encrypt(rand.Reader, &eciesPrivKey.PublicKey, message, nil, nil); err != nil {
		err = fmt.Errorf("Error creating ciphertext for ecies puzzle: %s", err)
		return
	}
	return
}
func CreateRSW2048A2PuzzleECIES ( t uint64 , message [ ] byte ) ( ciphertext [ ] byte , puzzle crypto . Puzzle , err error ) { var ecdsaPrivKey * ecdsa . PrivateKey if ecdsaPrivKey , err = ethcrypto . GenerateKey ( ) ; err != nil { err = fmt . Errorf ( " " , err ) return } var eciesPrivKeyBytes [ ] byte eciesPrivKeyBytes = ethcrypto . FromECDSA ( ecdsaPrivKey ) var timelock crypto . Timelock if timelock , err = rsw . New2048A2 ( eciesPrivKeyBytes ) ; err != nil { err = fmt . Errorf ( " " , err ) return } if puzzle , _ , err = timelock . SetupTimelockPuzzle ( t ) ; err != nil { err = fmt . Errorf ( " " , err ) return } var eciesPrivKey * ecies . PrivateKey eciesPrivKey = ecies . ImportECDSA ( ecdsaPrivKey ) if ciphertext , err = ecies . Encrypt ( rand . Reader , & eciesPrivKey . PublicKey , message , nil , nil ) ; err != nil { err = fmt . Errorf ( " " , err ) return } return }
CreateRSW2048A2PuzzleECIES creates a RSW timelock puzzle with time t and encrypts the message using ECIES.
CreateRSW2048A2PuzzleECIES creates a RSW timelock puzzle with time t and encrypts the message using ECIES .
// Generate ecdsa s256 // turn into bytes // Set up what the puzzle will encrypt (the ecies key, which we marshal using ASN.1 ECPKS) // Set up the puzzle to send // Actually get the ecies privkey that we sign with using the bytes from before. // Encrypt the message into the ciphertext so we can then send it out along with the puzzle // sharedInfo1 and sharedInfo2 (s1, s2) are not going to be needed (they are nil) because we assume no shared data // between the solver and creator of the puzzle. // We've now sent out the puzzle (which is n, a, t, ck)