!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";Uint8Array.prototype.fill||(Uint8Array.prototype.fill=Array.prototype.fill);const e=performance.now(),t=100,n=[],r=[],a=[],o=[],s=ristretto255.unsafe.point.alloc();for(let e=0;eristretto255.getRandom()},{name:"isValid",description:"Check if a value represents a valid element",execute:e=>ristretto255.isValid(r[e])},{name:"fromHash",description:"Hash to group: generate a group element from 64-element byte array, e.g. an output of SHA-512",execute:e=>ristretto255.fromHash(a[e])},{name:"add",description:"Add two group elements",execute:e=>ristretto255.add(r[e],r[(e+1)%t])},{name:"sub",description:"Subtract two group elements",execute:e=>ristretto255.sub(r[e],r[(e+1)%t])},{name:"scalarMultBase",description:"Multiply a generator of the group by a scalar",execute:e=>ristretto255.scalarMultBase(o[e])},{name:"scalarMult",description:"Multiply a group element by a scalar",execute:e=>ristretto255.scalarMult(o[e],r[e])}]},{name:"Scalar operations",functions:[{name:"scalar.getRandom",description:"Generate a random scalar",execute:()=>ristretto255.scalar.getRandom()},{name:"scalar.invert",description:"Invert a scalar",execute:e=>ristretto255.scalar.invert(o[e])},{name:"scalar.negate",description:"Negate a scalar",execute:e=>ristretto255.scalar.negate(o[e],o[e%t])},{name:"scalar.add",description:"Add two scalars",execute:e=>ristretto255.scalar.add(o[e],o[e%t])},{name:"scalar.sub",description:"Subtract two scalars",execute:e=>ristretto255.scalar.sub(o[e],o[e%t])},{name:"scalar.mul",description:"Multiply two scalars",execute:e=>ristretto255.scalar.mul(o[e],o[e%t])}]},{name:"Low-level unsafe functions (unless if used by a cryptographer)",functions:[{name:"unsafe.point.toBytes",description:"Serialize a curve25519 point to ristretto255 group element",execute:e=>ristretto255.unsafe.point.toBytes(n[e])},{name:"unsafe.point.fromBytes",description:"Deserialize a curve25519 point from ristretto255 group element",execute:e=>ristretto255.unsafe.point.fromBytes(s,r[e])},{name:"unsafe.point.getRandom",description:"Generate a random ristretto255 group element represented as curve25519 point",execute:()=>ristretto255.unsafe.point.getRandom()},{name:"unsafe.point.fromHash",description:"Generate a ristretto255 group element represented as curve25519 point from a 64 elements byte array such as an output of SHA512",execute:e=>ristretto255.unsafe.point.fromHash(a[e])},{name:"unsafe.point.add",description:"Add two curve25519 points",execute:e=>ristretto255.unsafe.point.add(n[e],n[e%t])},{name:"unsafe.point.sub",description:"Subtract two curve25519 points",execute:e=>ristretto255.unsafe.point.sub(n[e],n[e%t])},{name:"unsafe.point.scalarMultBase",description:"Multiply a curve25519's base point by a scalar",execute:e=>ristretto255.unsafe.point.scalarMultBase(n[e],o[e])},{name:"unsafe.point.scalarMult",description:"Multiply a curve25519's point by a scalar",execute:e=>ristretto255.unsafe.point.scalarMult(n[e],n[e%t],o[e])}]}].forEach((e=>{const n=e.functions.map((e=>{const n=[];for(let r=0;r ± ${a.toFixed(2)}`}}));document.getElementById("container").innerHTML+=((e,t)=>`\n

${e}

\n
\n \n \n \n \n \n \n ${t.map((e=>`\n \n \n \n \n \n `)).join("")}\n
Function nameTime in msComments
${e.functionName}${e.timing}${e.description}
\n
`)(e.name,n)}));const c=performance.now();document.getElementById("total_time").innerHTML=`Benchmark runtime: ${((c-e)/1e3).toFixed(2)} sec with 100 reps on each operation.`}));