func CreateRSW2048A2PuzzleRSA(t uint64, message []byte) (ciphertext []byte, puzzle crypto.Puzzle, err error) {
	// Generate private key
	var rsaPrivKey *rsa.PrivateKey
	if rsaPrivKey, err = rsa.GenerateMultiPrimeKey(rand.Reader, 2, 2048); err != nil {
		err = fmt.Errorf("Error generating key to encrypt ciphertext: %s", err)
		return
	}

	// Set up what the puzzle will encrypt (the rsa key, which we marshal using PKCS#1)
	var timelock crypto.Timelock
	if timelock, err = rsw.New2048A2(x509.MarshalPKCS1PrivateKey(rsaPrivKey)); err != nil {
		err = fmt.Errorf("Error creating new rsw timelock for rsa 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
	}

	// Encrypt the message into the ciphertext so we can then send it out along with the puzzle
	if ciphertext, err = rsa.EncryptPKCS1v15(rand.Reader, &rsaPrivKey.PublicKey, message); err != nil {
		err = fmt.Errorf("Error creating ciphertext for rsa puzzle: %s", err)
		return
	}

	// We've now sent out the puzzle (which is n, a, t, ck)

	return
}
// CreateRSW2048A2PuzzleRSA creates a RSW timelock puzzle with time t and encrypts the message using RSA. We marshal the key to PKCS1
CreateRSW2048A2PuzzleRSA creates a RSW timelock puzzle with time t and encrypts the message using RSA. We marshal the key to PKCS1
// CreateRSW2048A2PuzzleRSA creates a RSW timelock puzzle with time t and encrypts the message using RSA . We marshal the key to PKCS1
func CreateRSW2048A2PuzzleRSA(t uint64, message []byte) (ciphertext []byte, puzzle crypto.Puzzle, err error) {
	var rsaPrivKey *rsa.PrivateKey
	if rsaPrivKey, err = rsa.GenerateMultiPrimeKey(rand.Reader, 2, 2048); err != nil {
		err = fmt.Errorf("Error generating key to encrypt ciphertext: %s", err)
		return
	}
	var timelock crypto.Timelock
	if timelock, err = rsw.New2048A2(x509.MarshalPKCS1PrivateKey(rsaPrivKey)); err != nil {
		err = fmt.Errorf("Error creating new rsw timelock for rsa 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
	}
	if ciphertext, err = rsa.EncryptPKCS1v15(rand.Reader, &rsaPrivKey.PublicKey, message); err != nil {
		err = fmt.Errorf("Error creating ciphertext for rsa puzzle: %s", err)
		return
	}
	return
}
func CreateRSW2048A2PuzzleRSA ( t uint64 , message [ ] byte ) ( ciphertext [ ] byte , puzzle crypto . Puzzle , err error ) { var rsaPrivKey * rsa . PrivateKey if rsaPrivKey , err = rsa . GenerateMultiPrimeKey ( rand . Reader , 2 , 2048 ) ; err != nil { err = fmt . Errorf ( " " , err ) return } var timelock crypto . Timelock if timelock , err = rsw . New2048A2 ( x509 . MarshalPKCS1PrivateKey ( rsaPrivKey ) ) ; err != nil { err = fmt . Errorf ( " " , err ) return } if puzzle , _ , err = timelock . SetupTimelockPuzzle ( t ) ; err != nil { err = fmt . Errorf ( " " , err ) return } if ciphertext , err = rsa . EncryptPKCS1v15 ( rand . Reader , & rsaPrivKey . PublicKey , message ) ; err != nil { err = fmt . Errorf ( " " , err ) return } return }
CreateRSW2048A2PuzzleRSA creates a RSW timelock puzzle with time t and encrypts the message using RSA.
CreateRSW2048A2PuzzleRSA creates a RSW timelock puzzle with time t and encrypts the message using RSA .
// Generate private key // Set up what the puzzle will encrypt (the rsa key, which we marshal using PKCS#1) // Set up the puzzle to send // Encrypt the message into the ciphertext so we can then send it out along with the puzzle // We've now sent out the puzzle (which is n, a, t, ck)