aa.addAlterSign(privateKey, userOperation)

(Static Method)

Feature

Returns a user operation with alternative signature (proof_data of authentication) added using private key of sender of fact.

Parameters

object | instance UserOperation, // return value of createUserOperation string privateKey // privateKey of fact’s sender

Return Value

object HintedObject of UserOperation, The fields of op_sender and proxy_payer of settlement is empty.

// case1. use instance of userOperation as input
const userOp = mitum.aa.createUserOperation(op.fact, contract, "did:dxd:0x5279AebbF6e284594521d44612157147dF5ff248fca#auth_key");
const privateKey = "24e193a4765504f833eab39ab66c0073971a3bb344a16863268dfedbc178d7cbfpr";

const userOpWithAlterSign = mitum.aa.addAlterSign(privateKey, userOp);
console.log(userOpWithAlterSign);

// case2. use user operation object in json format
const userOp = {
  "_hint": "mitum-currency-transfer-operation-v0.0.1",
  "fact": {
    "_hint": "mitum-currency-transfer-operation-fact-v0.0.1",
    "hash": "EBiDGc2qr19MxrTjCPX1KtYkWL4V5D39g6EH2rKst6eY",
    "token": "MjAyNC0xMi0xNyAwNjozMDowNy45MDUgKzAwMDAgVVRD",
    "sender": "0x5279AebbF6e284594521d44612157147dF5ff248fca",
    "items": [
      {
        "_hint": "mitum-currency-transfer-item-multi-amounts-v0.0.1",
        "amounts": [
          {
            "_hint": "mitum-currency-amount-v0.0.1",
            "currency": "MCC",
            "amount": "10"
          }
        ],
        "receiver": "0x9E14a47B76F154A8e0f22cb213b3A1966800Ea0efca"
      }
    ]
  },
  "extension": {
    "authentication": {
      "_hint": "mitum-extension-base-authentication-v0.0.1",
      "contract": "0xdC521b33609647F949427A2330c136EfC3171535fca",
      "authentication_id": "did:dxd:0x5279AebbF6e284594521d44612157147dF5ff248fca#auth_key",
      "proof_data": ""
    },
    "settlement": {
      "_hint": "mitum-extension-base-settlement-v0.0.1",
      "op_sender": ""
    }
  },
  "hash": "",
  "signs": []
}

const privateKey = "24e193a4765504f833eab39ab66c0073971a3bb344a16863268dfedbc178d7cbfpr";

const userOpWithAlterSign = mitum.aa.addAlterSign(privateKey, userOp);
console.log(userOpWithAlterSign);

// outputs of case1 and case2 are same.
{
  _hint: 'mitum-currency-transfer-operation-v0.0.1',
  fact: {
    _hint: 'mitum-currency-transfer-operation-fact-v0.0.1',
    hash: 'EBiDGc2qr19MxrTjCPX1KtYkWL4V5D39g6EH2rKst6eY',
    token: 'MjAyNC0xMi0xNyAwNjozMDowNy45MDUgKzAwMDAgVVRD',
    sender: '0x5279AebbF6e284594521d44612157147dF5ff248fca',
    items: [ [Object] ]
  },
  extension: {
    authentication: {
      _hint: 'mitum-extension-base-authentication-v0.0.1',
      contract: '0xdC521b33609647F949427A2330c136EfC3171535fca',
      authentication_id: 'did:dxd:0x5279AebbF6e284594521d44612157147dF5ff248fca#auth_key',
      proof_data: '5BpRZ6B25Q6ufRrUypSfXN6gryWpNns1Sg2ANkWYdAWgmQRPr9B6495wER346ofU2F8JA2jPmp1EBYMAeEwQojKqPRsVg'
    },
    settlement: { _hint: 'mitum-extension-base-settlement-v0.0.1', op_sender: '' }
  },
  hash: '',
  signs: []
}

Last updated