0.0.1 • Published 1 year ago

payword-ts v0.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

#Payword

Broker create and sign a user certificate

const userCertification: UserCertification = {
      brokerId: 'brokerId',
      userId: 'userId',
      vendorId: 'vendorId',
      expirationDate: 123321,
      toAddress: 'toAddress',
      userPubKey: 'userPubKey'
    }

    const userCertificationSigned: UserCertificationSigned =
      generateUserCertification(userCertification, brokerPrivateKey)

User create a message and sign

const h0: string = 'hashzero'
const n = 100
const hashArray: string[] = getHashChainArrayByMessage(h0, n)
const hn: string = hashArray[n] ?? ''

const userMessage: UserMessage = {
  expirationDate: 123321,
  userCertificationSigned,
  vendorId: 'vendorId',
  hn,
  n
}

const userMessageSigned: UserMessageSigned = generateUserMessageSigned(
  userPrivateKey,
  userMessage
)

User create the payword

const payWord: PayWord = { j, hj: getHashChainItemByMessage(h0, j) }

Anyone can verify

verifyUserCertificationSigned(userCertificationSigned,brokerPublicKey) // validate only the user certifiation
verifyUserMessageSigned(userMessageSigned, userPublicKey) // validate only the user message
isPayWordValid(payWord, userMessageSigned, brokerPublicKey, userPublicKey) // validate only the payword

Also, it is possible to generate the hashchain

hash('John')
getHashChainItemByMessage('John', 10) // returns the 10th hash
getHashChainArrayByMessage('John', 10) // returns a hashchain of length 10
0.0.2-beta.1

1 year ago

0.0.1

1 year ago