Skip to content

Commit

Permalink
Fix UI to ensure random button on scalar mul works + ensure multiplic…
Browse files Browse the repository at this point in the history
…ative inverse work without a second field element loaded
  • Loading branch information
iamalwaysuncomfortable committed Jan 27, 2025
1 parent d89181c commit f2c73e8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions website/src/tabs/algebra/FieldArithmetic.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export const FieldArithmetic = () => {
};

const calculateResult = (num1, num2, op) => {
if ((op === "inv" && num1 === "") ||
(op !== "inv" && (num1 === "" || num2 === ""))) {
if (((op === "inv" || op === "mulinv") && num1 === "") ||
((op !== "inv" && op !== "mulinv") && (num1 === "" || num2 === ""))) {
setResult("");
return;
}
Expand Down
8 changes: 7 additions & 1 deletion website/src/tabs/algebra/GroupArithmetic.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ export const GroupArithmetic = () => {
calculateResult(groupValueOne, newValue, operation);
};

const onScalarRandom = () => {
const newValue = generateRandomScalar();
setScalarValue(newValue);
calculateResult(groupValueOne, groupValueTwo, operation, newValue);
}

const layout = {
labelCol: { span: 6 },
wrapperCol: { span: 18 },
Expand Down Expand Up @@ -264,7 +270,7 @@ export const GroupArithmetic = () => {
/>
<Button
size="large"
onClick={() => setScalarValue(generateRandomScalar())}
onClick={onScalarRandom}
style={{ width: '110px' }}
>
Random
Expand Down

0 comments on commit f2c73e8

Please sign in to comment.