Promon SHIELD attestation token references
  • JavaScript 100%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-25 15:00:00 +00:00
com.supercell.brawlstars attestations: v70 reference 2026-11-25 15:00:00 +00:00
README.md attestations: v70 reference 2026-11-25 15:00:00 +00:00

attestations

Offline references for the Promon SHIELD attestation token: for a given 32-byte challenge, what the 80-byte token the shield returns is, plus the request envelope that carries it (challenge, timestamp, HMAC signature).

Every constant is per build, so there is one module per app and version, named <package>/v<version>.js (com.supercell.brawlstars/v70.js). Modules are plain CommonJS, no dependencies, no native code; require() one, or run it directly:

node com.supercell.brawlstars/v70.js <challenge-hex(64)> [timestamp] [salt-hex]

The token is ten little-endian u64 words:

d[0] = salt
d[1] = d[0]*N + timestamp
d[k] = d[k-1]*N + x[k]        x = e,s,c,f,g,w,y,h

with N = 1027, all arithmetic mod 2^64, and the derived words from the challenge: e,i,o,a = challenge as 4 LE u64, s = i - N*e, c = o - N*i, f = a - N*o. g,w,y,h are the build's HMAC-SHA256 PRF over e,s,c,f, resumed from two per-build midstates.

Each module exports generateToken(challenge, { timestamp, salt, midstates }), a signChallenge() for the request envelope, and performAttestation() which does one round (deterministic parts only, no transport).

Template

Copy this into <package>/v<version>.js and fill the constants. com.supercell.brawlstars/v70.js is the complete, tested implementation — use it as the reference for the trimmed helpers below.

'use strict';

/**
 * v<version>.js — <app name> attestation token.
 * Shield build: <promon version>    Source: promon attest <tree> --dump-material
 */

const crypto = require('node:crypto');

// --- 1. per-build constants (REPLACE) --------------------------------------
const SALT = 0x0000000000000000n;                 // d[0] of any emitted token
const MIDSTATES = Buffer.from('00'.repeat(64), 'hex'); // "vm64 decoded": A || B
const I_IV = Buffer.from('00'.repeat(32), 'hex');      // reference only

const N = 1027n;
const MASK64 = (1n << 64n) - 1n;

// --- 2. SHA-256 compression ------------------------------------------------
//     K table, rotr(), compress(), pad(), rev32() — verbatim from v70.js.

// --- 3. PRF ----------------------------------------------------------------
/** HMAC-SHA256 resumed from the build's midstates. */
function prfFromMidstates(keyBytes, midstates = MIDSTATES) {
  // inner = H(A, pad_768(key)); outer = H(B, pad_768(rev32(inner)))
  // return rev32(outer)  ->  g,w,y,h as LE words
}

// --- 4. token --------------------------------------------------------------
function generateToken(challenge, opts = {}) {
  // e,i,o,a = challenge as 4 LE u64
  // s = i - N*e; c = o - N*i; f = a - N*o
  // prf = prfFromMidstates(pack(e,s,c,f))
  // chain salt + timestamp + e,s,c,f,g,w,y,h  -> 10 LE u64 words
}

// --- 5. request envelope ---------------------------------------------------
/** HMAC-SHA256(secret, challenge || ts_le), base64. */
function signChallenge(challenge, timestamp, secret) {
  const msg = Buffer.alloc(36);
  Buffer.from(challenge).copy(msg, 0, 0, 32);
  msg.writeUInt32LE(timestamp >>> 0, 32);
  return crypto.createHmac('sha256', secret).update(msg).digest('base64');
}

function performAttestation({ challenge, timestamp, secret, salt, midstates } = {}) {
  const request = {
    t: 'attest',
    challenge: Buffer.from(challenge).toString('hex'),
    timestamp,
    signature: secret ? signChallenge(challenge, timestamp, secret) : null,
  };
  const token = generateToken(challenge, { timestamp, salt, midstates });
  return { request, token, tokenHex: token.toString('hex') };
}

module.exports = { N, SALT, MIDSTATES, I_IV,
                   prfFromMidstates, generateToken, signChallenge, performAttestation };

Basics

Capture the constants for a new build with:

promon attest <tree> --dump-material
  • salt (runtime) → SALT; vm64 decoded → MIDSTATES. Both are per shield build, not per challenge, and the midstates are generated at runtime, so they have to be dumped, not derived from the library.
  • The salt is recoverable from any single captured token (d[0]), so it never needs guessing.
  • A token is bound to its timestamp; the server accepts ±5 minutes, so old captures are known-answer vectors, not replays.
  • token.rs's HMAC(key = e,s,c,f, data = I_IV) model does not reproduce the output; the verified construction is the midstate PRF above. I_IV is kept only for comparison.
  • Use BigInt for the chain — JS numbers lose precision above 2^53.
  • The transport is out of scope: the token travels AES-256-GCM-encrypted (nonce(12) ‖ ciphertext(80) ‖ tag(16)), the modules stop at the plaintext.

Reference material for interoperability and analysis; use it only against apps and accounts you're authorised to test.