static int matchAddress(const struct display *d, struct _matchAddress *a) { if (d->displayType.origin == FromXDMCP && d->displayNumber == a->displayNumber && addressEqual(d->from, d->fromlen, a->addr, a->addrlen)) return 1; return 0; }
struct display *FindDisplayByAddress(XdmcpNetaddr addr, int addrlen, CARD16 displayNumber) { struct display *d; for(d = displays; d; d = d->next) if((d->displayType & d_origin) == dFromXDMCP && d->displayNumber == displayNumber && addressEqual((XdmcpNetaddr)d->from.data, d->from.length, addr, addrlen)) return d; return 0; }
ewm->client.funcEWMEvent (ewm->client.context, ewm, //event->wid, // event->tid, event, status, errorDescription); } #if 0 // Transaction BREthereumTransactionId tid = -1; BREthereumAddress primaryAddress = accountGetPrimaryAddress(ewm->account); assert (ETHEREUM_BOOLEAN_IS_TRUE(addressEqual(primaryAddress, bundle->from)) || ETHEREUM_BOOLEAN_IS_TRUE(addressEqual(primaryAddress, bundle->to))); // primaryAddress is either the transaction's `source` or `target`. BREthereumBoolean isSource = addressEqual(primaryAddress, bundle->from); BREthereumWalletId wid = ewmGetWallet(ewm); BREthereumWallet wallet = ewmLookupWallet(ewm, wid); BREthereumBlock block = ewmLookupBlockByHash(ewm, bundle->blockHash); block = blockCreateMinimal(bundle->blockHash, bundle->blockNumber, bundle->blockTimestamp); ewmSignalBlockEvent(ewm, ewmInsertBlock(ewm, block), BLOCK_EVENT_CREATED, SUCCESS, NULL); // Look for a pre-existing transaction
static void runSignatureTests1 (void) { printf ("\n== Signature 1\n"); UInt256 digest; printf (" Data:\n"); char *signingData = SIGNATURE_SIGNING_DATA; char *signingHash = SIGNATURE_SIGNING_HASH; size_t signingBytesCount = 0; uint8_t *signingBytes = decodeHexCreate(&signingBytesCount, signingData, strlen (signingData)); BRKeccak256(&digest, signingBytes, signingBytesCount); char *digestString = encodeHexCreate(NULL, (uint8_t *) &digest, sizeof(UInt256)); printf (" Hex: %s\n", digestString); assert (0 == strcmp (digestString, signingHash)); BRKey privateKeyUncompressed; BRKeySetPrivKey(&privateKeyUncompressed, SIGNATURE_PRIVATE_KEY); size_t signatureLen = BRKeyCompactSign(&privateKeyUncompressed, NULL, 0, digest); // RAW (using directly BRKeyCompactSign) uint8_t signatureBytes[signatureLen]; signatureLen = BRKeyCompactSign(&privateKeyUncompressed, signatureBytes, signatureLen, digest); assert (65 == signatureLen); char *signatureHex = encodeHexCreate(NULL, signatureBytes, signatureLen); printf (" SigRaw: %s\n", signatureHex); assert (130 == strlen(signatureHex)); assert (0 == strncmp (&signatureHex[ 0], SIGNATURE_V, 2)); assert (0 == strncmp (&signatureHex[ 2], SIGNATURE_R, 64)); assert (0 == strncmp (&signatureHex[66], SIGNATURE_S, 64)); // Setup int success; size_t sigRDataLen, sigSDataLen; uint8_t *sigRData, *sigSData; sigRData = decodeHexCreate(&sigRDataLen, SIGNATURE_R, strlen (SIGNATURE_R)); sigSData = decodeHexCreate(&sigSDataLen, SIGNATURE_S, strlen (SIGNATURE_S)); assert (32 == sigRDataLen & 32 == sigSDataLen); // VRS printf (" SigVRS\n"); BREthereumSignature sigVRS = signatureCreate (SIGNATURE_TYPE_RECOVERABLE_VRS_EIP, signingBytes, signingBytesCount, privateKeyUncompressed); assert (sigVRS.sig.vrs.v == 0x1b); assert (0 == memcmp (sigVRS.sig.vrs.r, sigRData, sigRDataLen)); assert (0 == memcmp (sigVRS.sig.vrs.s, sigSData, sigSDataLen)); BREthereumAddress addrVRS = signatureExtractAddress (sigVRS, signingBytes, signingBytesCount, &success); assert (1 == success); // RSV printf (" SigRSV\n"); BREthereumSignature sigRSV = signatureCreate (SIGNATURE_TYPE_RECOVERABLE_RSV, signingBytes, signingBytesCount, privateKeyUncompressed); assert (sigRSV.sig.rsv.v == 0x00); assert (0 == memcmp (sigRSV.sig.rsv.r, sigRData, sigRDataLen)); assert (0 == memcmp (sigRSV.sig.rsv.s, sigSData, sigSDataLen)); BREthereumAddress addrRSV = signatureExtractAddress (sigRSV, signingBytes, signingBytesCount, &success); assert (1 == success); assert (ETHEREUM_BOOLEAN_TRUE == addressEqual (addrVRS, addrRSV)); }