Skip to content

Comments

Add Quantum Randomness extension for Scratch#513

Open
DashDevmationsDash wants to merge 1 commit intoPenguinMod:mainfrom
DashDevmationsDash:patch-4
Open

Add Quantum Randomness extension for Scratch#513
DashDevmationsDash wants to merge 1 commit intoPenguinMod:mainfrom
DashDevmationsDash:patch-4

Conversation

@DashDevmationsDash
Copy link

@DashDevmationsDash DashDevmationsDash commented Feb 12, 2026

Its Cool Ig

Name:Quantum Randomness
Desc:Use The ANU Quantum Randomness Api To Geneate True Random Numbers!

Thumb:
Thumbnail

@the-can-of-soup
Copy link

this could be cool

@JeremyGamer13 JeremyGamer13 added the new extension This extension is brand new to the repository label Feb 12, 2026
@DashDevmationsDash
Copy link
Author

jeremy adding the new extension label:
fFCfn6

@Steve0Greatness
Copy link
Contributor

Steve0Greatness commented Feb 17, 2026

Just so you're aware, extension thumbnails are in a 2:1 aspect ratio, meaning they're twice as wide as they are tall. Your thumbnail is 23:18, meaning some of your thumbnail will be cut off when loaded onto the website. This would likely include the wordmark, so I'd personally suggest redoing it.

Comment on lines +86 to +89
} catch (error) {
console.warn("Quantum API failed, using Math.random()", error);
return Math.floor(min + Math.random() * (max - min + 1));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably be using the web-crypto method getRandomValues here, as it's closer to true random than Math.random is.

const value = new Uint8Array(1);
crypto.getRandomValues(value);
return Math.floor(min + (value[0]/255) * (max - min + 1));

);
clearTimeout(timeout);
const json = await response.json();
const quantumValue = json.data[0] / 256;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation specifies that the number will always be between 0 and 255, not 256, so this should be dividing by 255.

if (min === max) return min;
try {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 3000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd specify a message to say that this abortion was because it got timed out.

(function (Scratch) {
'use strict';

let apikey = '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is global state, it might be a good idea to add a serializer for this so it doesn't need to be set on project start each time.


let apikey = '';

class Extension {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a requirement, but it'd be nice if this were named something relevant rather than just "Extension."

"4. Locate your API Key section.\n\n" +
"5. Copy your Free API Key.\n\n" +
"6. Paste it into the 'Set Api Key' block.\n\n" +
"Pro Tip: Try Encoding Your Api Key Cuz In A Site Where Seeing The Code Of Projects Is As Easy As A Click Of A Button... You Will Need It"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security through obscurity is not real security, it's like hiding spare keys under a rock in your yard. Sure, nobody will know it's there unless you tell them, or they scope it out, but if they know it's there, then it's pretty easy to break into your house.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not even that. its REALLY easy to find the api key. you can just look at the network tab in inspect element.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm
image

color1: '#21ab61',
blocks: [
{
opcode: 'how2getapikey',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Buttons don't need opcodes, this can just use the func key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new extension This extension is brand new to the repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants