Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Construction combine #109

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Construction combine #109

wants to merge 7 commits into from

Conversation

piotr-iohk
Copy link
Collaborator

Addressing #88.

So /construction/combine takes unsigned_transaction from the /construction/payloads output and combines it with the signature producing signed_transaction as output. The unsigned_transaction is signed outside MinaMesh. AFAIK there are following signers available:

Documentation on signing: https://docs.minaprotocol.com/exchange-operators/rosetta/samples/using-signer.

1. Sign

Using Ocaml-signer the transaction can be signed as follows:

$ signer.exe generate-private-key
114C280242641B5E7689B3A7361E90A775EF61BB6F8C32E106123D48FF704410

$ signer.exe sign -unsigned-transaction "{\"randomOracleInput\":\"000000035E6737A0AC0A147918437FC8C21EA57CECFB613E711CA2E4FD328401657C291C5E6737A0AC0A147918437FC8C21EA57CECFB613E711CA2E4FD328401657C291C5E6737A0AC0A147918437FC8C21EA57CECFB613E711CA2E4FD328401657C291C000002570561800000000000800000000000000081F0000001586000401013570767000000000000000000000000000000000000000000000000000000000E0000000000000000013E815200000000\",\"signerInput\":{\"prefix\":[\"5E6737A0AC0A147918437FC8C21EA57CECFB613E711CA2E4FD328401657C291C\",\"5E6737A0AC0A147918437FC8C21EA57CECFB613E711CA2E4FD328401657C291C\",\"5E6737A0AC0A147918437FC8C21EA57CECFB613E711CA2E4FD328401657C291C\"],\"suffix\":[\"0001CDC1D5901004000C350000001F0200000000000000020000000000030D40\",\"0000000003800000000000000000000000000000000000000000000000000000\",\"00000000000000000000000000000000000000000000000009502F9000000000\"]},\"payment\":{\"to\":\"B62qoDWfBZUxKpaoQCoFqr12wkaY84FrhxXNXzgBkMUi2Tz4K8kBDiv\",\"from\":\"B62qoDWfBZUxKpaoQCoFqr12wkaY84FrhxXNXzgBkMUi2Tz4K8kBDiv\",\"fee\":\"100000\",\"token\":\"1\",\"nonce\":\"1984\",\"memo\":\"dups\",\"amount\":\"5000000000\",\"valid_until\":\"200000\"},\"stakeDelegation\":null}" \
                  -private-key 114C280242641B5E7689B3A7361E90A775EF61BB6F8C32E106123D48FF704410
EE1D10B5EF283026177B8C61F75C84F09B35C94C6D1417C2C88707E2D26CBB21D1371F16F3AEC696E055C235D9EA2F707630EB395813AEBFE120BBDD5B5E8908

2. Combine

curl -X POST 'http://localhost:3000/construction/combine' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
   "network_identifier":{
	  "blockchain":"mina",
	  "network":"devnet"
   },
   "signatures":[
	  {
		 "hex_bytes":"EE1D10B5EF283026177B8C61F75C84F09B35C94C6D1417C2C88707E2D26CBB21D1371F16F3AEC696E055C235D9EA2F707630EB395813AEBFE120BBDD5B5E8908",
		 "signature_type":"schnorr_poseidon",
		 "public_key":{
			"curve_type":"tweedle",
			"hex_bytes":"xxx"
		 },
		 "signing_payload":{
			"hex_bytes":"xxx"
		 }
	  }
   ],
   "unsigned_transaction":"{\"randomOracleInput\":\"000000033024262EC0279FAE8D8984B4DFF694E3DE1A8513B8DB9E13A2BA190581EC974A3024262EC0279FAE8D8984B4DFF694E3DE1A8513B8DB9E13A2BA190581EC974A5E6737A0AC0A147918437FC8C21EA57CECFB613E711CA2E4FD328401657C291C000002570561800000000000800000000000000081F0000001586000407C0382808784808087848080A1C2A1C287848080C30607848080C10784808086000E0000000000000000013E815200000000\",\"signerInput\":{\"prefix\":[\"3024262EC0279FAE8D8984B4DFF694E3DE1A8513B8DB9E13A2BA190581EC974A\",\"3024262EC0279FAE8D8984B4DFF694E3DE1A8513B8DB9E13A2BA190581EC974A\",\"5E6737A0AC0A147918437FC8C21EA57CECFB613E711CA2E4FD328401657C291C\"],\"suffix\":[\"0243C20283807C04000C350000001F0200000000000000020000000000030D40\",\"000000000380030808090F041808090F03061808090F0A1C2A1C2808090F0808\",\"00000000000000000000000000000000000000000000000009502F9000000000\"]},\"payment\":{\"to\":\"B62qoDWfBZUxKpaoQCoFqr12wkaY84FrhxXNXzgBkMUi2Tz4K8kBDiv\",\"from\":\"B62qoze6jaLrEyBEj1Jkr9wRrpQ4VLaLx5EoDJawQgReYWXywmBU1mx\",\"fee\":\"100000\",\"token\":\"1\",\"nonce\":\"1984\",\"memo\":\"ࠀ𐀀𐀀¡¡𐀀a0𐀀A𐀀0\",\"amount\":\"5000000000\",\"valid_until\":\"200000\"},\"stakeDelegation\":null}"
}' | jq

👇

{
  "signed_transaction": "{\"signature\":\"EE1D10B5EF283026177B8C61F75C84F09B35C94C6D1417C2C88707E2D26CBB21D1371F16F3AEC696E055C235D9EA2F707630EB395813AEBFE120BBDD5B5E8908\",\"payment\":{\"to\":\"B62qoDWfBZUxKpaoQCoFqr12wkaY84FrhxXNXzgBkMUi2Tz4K8kBDiv\",\"from\":\"B62qoze6jaLrEyBEj1Jkr9wRrpQ4VLaLx5EoDJawQgReYWXywmBU1mx\",\"fee\":\"100000\",\"token\":\"1\",\"nonce\":\"1984\",\"memo\":\"ࠀ𐀀𐀀¡¡𐀀a0𐀀A𐀀0\",\"amount\":\"5000000000\",\"valid_until\":\"200000\"},\"stake_delegation\":null}"
}

Notes:

  • Although /construction/combine allows many signatures (signatures: Vec<models::Signature>) only the first one is read, therefore I've added check to allow only 1 signature (which does not exist in Ocaml)
  • The signature type is:
pub struct Signature {
    #[serde(rename = "signing_payload")]
    pub signing_payload: Box<models::SigningPayload>,
    #[serde(rename = "public_key")]
    pub public_key: Box<models::PublicKey>,
    #[serde(rename = "signature_type")]
    pub signature_type: models::SignatureType,
    #[serde(rename = "hex_bytes")]
    pub hex_bytes: String,
}

however in Ocaml the signing_payload and public_key are not verified, therefore here we also only validate the hex_bytes verifying if it can be successfully decoded into mina_signer::Signature, we also verify if SignatureType is SignatureType::SchnorrPoseidon.

  • since Rosetta Ocaml has it's own signer perhaps we should also consider adding one into MinaMesh 💡 .

@piotr-iohk piotr-iohk self-assigned this Feb 20, 2025
@johnmarcou johnmarcou removed their request for review February 20, 2025 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant