Type casting in Magma
$begingroup$
I'm doing a Magma implementation of the Camellia block chiper for an university project.
I'm facing an annoying problem, I have a sequence, representing a binary value, that I need to convert to an Integer value and then to a String, so I've created a function that convert the binary form into an integer value
My problem is that every element of that sequence and also the result of the conversion to inger are defined as FldFInElt, but in order to use the function IntegerToString I need a parameter of type RngIntElt.
I'm not figuring out how to do this casting, the usual one with the ! operator throw an error for Invalid coercion.
Does anyone know how to solve this?
Thanks.
math-software computer-algebra-systems magma-cas
$endgroup$
add a comment |
$begingroup$
I'm doing a Magma implementation of the Camellia block chiper for an university project.
I'm facing an annoying problem, I have a sequence, representing a binary value, that I need to convert to an Integer value and then to a String, so I've created a function that convert the binary form into an integer value
My problem is that every element of that sequence and also the result of the conversion to inger are defined as FldFInElt, but in order to use the function IntegerToString I need a parameter of type RngIntElt.
I'm not figuring out how to do this casting, the usual one with the ! operator throw an error for Invalid coercion.
Does anyone know how to solve this?
Thanks.
math-software computer-algebra-systems magma-cas
$endgroup$
$begingroup$
What is the order of your field? I'm not having any problem coercing elements of $mathbb{F}_{7}$ into $mathbb{Z}$ using !
$endgroup$
– Morgan Rodgers
Dec 17 '18 at 17:10
$begingroup$
I have defined B := VectorSpace(GF(2),8); I've been able to solve it: the problem was only with vectors representing decimal '0' and '1' because magma was considering them as coefficients of GF(2) so the sum operation was performed in GF(2), so it was a bitwise XOR
$endgroup$
– Marco
Dec 18 '18 at 9:30
$begingroup$
Magma was considering them as being in GF(2) because you defined the vector space to be over GF(2). If this was an easy fix, you should consider deleting your question; if it was something you think is useful to share, you can share your solution as an answer.
$endgroup$
– Morgan Rodgers
Dec 19 '18 at 6:27
$begingroup$
Yes, the "solution" that I've found is just a workaroud because i'm creating a copy of the sequence that has values of Z, I was seraching a better solution in terms of performance and elegance. That conversion is involved in the implementation of Camellia block cipher and even if it is performed only on an 8 bit sequence it is called many times, I'm searching something that will allow me to avoid a FOR loop and save time.
$endgroup$
– Marco
Dec 19 '18 at 15:27
$begingroup$
If you are still looking for someone to help with a good solution, you should include some details. For example, if you include the code you are currently using to convert your sequence to an integer, someone may be able to help improve it.
$endgroup$
– Morgan Rodgers
Dec 19 '18 at 15:50
add a comment |
$begingroup$
I'm doing a Magma implementation of the Camellia block chiper for an university project.
I'm facing an annoying problem, I have a sequence, representing a binary value, that I need to convert to an Integer value and then to a String, so I've created a function that convert the binary form into an integer value
My problem is that every element of that sequence and also the result of the conversion to inger are defined as FldFInElt, but in order to use the function IntegerToString I need a parameter of type RngIntElt.
I'm not figuring out how to do this casting, the usual one with the ! operator throw an error for Invalid coercion.
Does anyone know how to solve this?
Thanks.
math-software computer-algebra-systems magma-cas
$endgroup$
I'm doing a Magma implementation of the Camellia block chiper for an university project.
I'm facing an annoying problem, I have a sequence, representing a binary value, that I need to convert to an Integer value and then to a String, so I've created a function that convert the binary form into an integer value
My problem is that every element of that sequence and also the result of the conversion to inger are defined as FldFInElt, but in order to use the function IntegerToString I need a parameter of type RngIntElt.
I'm not figuring out how to do this casting, the usual one with the ! operator throw an error for Invalid coercion.
Does anyone know how to solve this?
Thanks.
math-software computer-algebra-systems magma-cas
math-software computer-algebra-systems magma-cas
asked Dec 17 '18 at 10:23
MarcoMarco
1011
1011
$begingroup$
What is the order of your field? I'm not having any problem coercing elements of $mathbb{F}_{7}$ into $mathbb{Z}$ using !
$endgroup$
– Morgan Rodgers
Dec 17 '18 at 17:10
$begingroup$
I have defined B := VectorSpace(GF(2),8); I've been able to solve it: the problem was only with vectors representing decimal '0' and '1' because magma was considering them as coefficients of GF(2) so the sum operation was performed in GF(2), so it was a bitwise XOR
$endgroup$
– Marco
Dec 18 '18 at 9:30
$begingroup$
Magma was considering them as being in GF(2) because you defined the vector space to be over GF(2). If this was an easy fix, you should consider deleting your question; if it was something you think is useful to share, you can share your solution as an answer.
$endgroup$
– Morgan Rodgers
Dec 19 '18 at 6:27
$begingroup$
Yes, the "solution" that I've found is just a workaroud because i'm creating a copy of the sequence that has values of Z, I was seraching a better solution in terms of performance and elegance. That conversion is involved in the implementation of Camellia block cipher and even if it is performed only on an 8 bit sequence it is called many times, I'm searching something that will allow me to avoid a FOR loop and save time.
$endgroup$
– Marco
Dec 19 '18 at 15:27
$begingroup$
If you are still looking for someone to help with a good solution, you should include some details. For example, if you include the code you are currently using to convert your sequence to an integer, someone may be able to help improve it.
$endgroup$
– Morgan Rodgers
Dec 19 '18 at 15:50
add a comment |
$begingroup$
What is the order of your field? I'm not having any problem coercing elements of $mathbb{F}_{7}$ into $mathbb{Z}$ using !
$endgroup$
– Morgan Rodgers
Dec 17 '18 at 17:10
$begingroup$
I have defined B := VectorSpace(GF(2),8); I've been able to solve it: the problem was only with vectors representing decimal '0' and '1' because magma was considering them as coefficients of GF(2) so the sum operation was performed in GF(2), so it was a bitwise XOR
$endgroup$
– Marco
Dec 18 '18 at 9:30
$begingroup$
Magma was considering them as being in GF(2) because you defined the vector space to be over GF(2). If this was an easy fix, you should consider deleting your question; if it was something you think is useful to share, you can share your solution as an answer.
$endgroup$
– Morgan Rodgers
Dec 19 '18 at 6:27
$begingroup$
Yes, the "solution" that I've found is just a workaroud because i'm creating a copy of the sequence that has values of Z, I was seraching a better solution in terms of performance and elegance. That conversion is involved in the implementation of Camellia block cipher and even if it is performed only on an 8 bit sequence it is called many times, I'm searching something that will allow me to avoid a FOR loop and save time.
$endgroup$
– Marco
Dec 19 '18 at 15:27
$begingroup$
If you are still looking for someone to help with a good solution, you should include some details. For example, if you include the code you are currently using to convert your sequence to an integer, someone may be able to help improve it.
$endgroup$
– Morgan Rodgers
Dec 19 '18 at 15:50
$begingroup$
What is the order of your field? I'm not having any problem coercing elements of $mathbb{F}_{7}$ into $mathbb{Z}$ using !
$endgroup$
– Morgan Rodgers
Dec 17 '18 at 17:10
$begingroup$
What is the order of your field? I'm not having any problem coercing elements of $mathbb{F}_{7}$ into $mathbb{Z}$ using !
$endgroup$
– Morgan Rodgers
Dec 17 '18 at 17:10
$begingroup$
I have defined B := VectorSpace(GF(2),8); I've been able to solve it: the problem was only with vectors representing decimal '0' and '1' because magma was considering them as coefficients of GF(2) so the sum operation was performed in GF(2), so it was a bitwise XOR
$endgroup$
– Marco
Dec 18 '18 at 9:30
$begingroup$
I have defined B := VectorSpace(GF(2),8); I've been able to solve it: the problem was only with vectors representing decimal '0' and '1' because magma was considering them as coefficients of GF(2) so the sum operation was performed in GF(2), so it was a bitwise XOR
$endgroup$
– Marco
Dec 18 '18 at 9:30
$begingroup$
Magma was considering them as being in GF(2) because you defined the vector space to be over GF(2). If this was an easy fix, you should consider deleting your question; if it was something you think is useful to share, you can share your solution as an answer.
$endgroup$
– Morgan Rodgers
Dec 19 '18 at 6:27
$begingroup$
Magma was considering them as being in GF(2) because you defined the vector space to be over GF(2). If this was an easy fix, you should consider deleting your question; if it was something you think is useful to share, you can share your solution as an answer.
$endgroup$
– Morgan Rodgers
Dec 19 '18 at 6:27
$begingroup$
Yes, the "solution" that I've found is just a workaroud because i'm creating a copy of the sequence that has values of Z, I was seraching a better solution in terms of performance and elegance. That conversion is involved in the implementation of Camellia block cipher and even if it is performed only on an 8 bit sequence it is called many times, I'm searching something that will allow me to avoid a FOR loop and save time.
$endgroup$
– Marco
Dec 19 '18 at 15:27
$begingroup$
Yes, the "solution" that I've found is just a workaroud because i'm creating a copy of the sequence that has values of Z, I was seraching a better solution in terms of performance and elegance. That conversion is involved in the implementation of Camellia block cipher and even if it is performed only on an 8 bit sequence it is called many times, I'm searching something that will allow me to avoid a FOR loop and save time.
$endgroup$
– Marco
Dec 19 '18 at 15:27
$begingroup$
If you are still looking for someone to help with a good solution, you should include some details. For example, if you include the code you are currently using to convert your sequence to an integer, someone may be able to help improve it.
$endgroup$
– Morgan Rodgers
Dec 19 '18 at 15:50
$begingroup$
If you are still looking for someone to help with a good solution, you should include some details. For example, if you include the code you are currently using to convert your sequence to an integer, someone may be able to help improve it.
$endgroup$
– Morgan Rodgers
Dec 19 '18 at 15:50
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3043772%2ftype-casting-in-magma%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3043772%2ftype-casting-in-magma%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
What is the order of your field? I'm not having any problem coercing elements of $mathbb{F}_{7}$ into $mathbb{Z}$ using !
$endgroup$
– Morgan Rodgers
Dec 17 '18 at 17:10
$begingroup$
I have defined B := VectorSpace(GF(2),8); I've been able to solve it: the problem was only with vectors representing decimal '0' and '1' because magma was considering them as coefficients of GF(2) so the sum operation was performed in GF(2), so it was a bitwise XOR
$endgroup$
– Marco
Dec 18 '18 at 9:30
$begingroup$
Magma was considering them as being in GF(2) because you defined the vector space to be over GF(2). If this was an easy fix, you should consider deleting your question; if it was something you think is useful to share, you can share your solution as an answer.
$endgroup$
– Morgan Rodgers
Dec 19 '18 at 6:27
$begingroup$
Yes, the "solution" that I've found is just a workaroud because i'm creating a copy of the sequence that has values of Z, I was seraching a better solution in terms of performance and elegance. That conversion is involved in the implementation of Camellia block cipher and even if it is performed only on an 8 bit sequence it is called many times, I'm searching something that will allow me to avoid a FOR loop and save time.
$endgroup$
– Marco
Dec 19 '18 at 15:27
$begingroup$
If you are still looking for someone to help with a good solution, you should include some details. For example, if you include the code you are currently using to convert your sequence to an integer, someone may be able to help improve it.
$endgroup$
– Morgan Rodgers
Dec 19 '18 at 15:50